I always sort the data in the memory. Although I have never do research on it, but logicaly this must be faster as do a new request to the database. Why ? Because sorting in the memory doesn't need to copy all the data once more, what you have to do by a new database request. Sort in the memory just reordered the index, whether you use value object in an array (see the previous discussion about sorting in array) or other collection classes. Copying the data costs the most time of the whole process plus the cost of transporting the new requested data from the database into the cache. The disadvantage of this solution is, that you cannot see the newest data (if there are any !) until you do a new request.
I hope this will help you choosing where you sort the data. regards Chao Ying -----Urspr�ngliche Nachricht----- Von: Repine, Burt [mailto:[EMAIL PROTECTED]] Gesendet: Thursday, May 30, 2002 12:02 AM An: JDJList Betreff: �jdjlist� sorting records Hello all - I have a requirement to retrieve n number of records from a database using JDBC and then display those records to the user. The user can then sort those records if they so choose. Would it be faster/less resource intensive to go back to the database with a new 'order by' SQL statement OR sort the records as a Collection in the Java code? Thanks for the help, Burt To change your membership options, refer to: http://www.sys-con.com/java/list.cfm To change your membership options, refer to: http://www.sys-con.com/java/list.cfm
