Hi,

The decision would also depend on the column on which sorting take place.If it is 
numerical AND the number of records fetched are not too many, then sorting at the 
collection size would be an optimal solution.
If it is to be sorted on say a date or string .. then probably the database would do a 
better job of it.

Keep this in mind - Database are meant to sort records .. which is why there are 
indexes in existance.
Collections are meant to only hold objects.Sorting on collections will always incur an 
overhead of retrieving and comparing element(which is why I said the column shd be 
numeric).

-Sandy

On Wed, 29 May 2002 20:37:21  
 Jason Kilgrow wrote:
>I think it would depend on how many records you are retrieving and how you are 
>retrieving them. For instance, if you are talking about 1000 records or more, a new 
>query might be the way to go. Also, using a PreparedStatement would be faster in this 
>case than using a Statement.
>
>If I were to research this problem, I would run some tests to see which way was 
>fastest. That is going to be the best way to tell which is best anyway. Anything but 
>hard test data is speculation.
>
>"Repine, Burt" <[EMAIL PROTECTED]> wrote:
>
>>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
>>
>
>
>__________________________________________________________________
>Your favorite stores, helpful shopping tools and great gift ideas. Experience the 
>convenience of buying online with Shop@Netscape! http://shopnow.netscape.com/
>
>Get your own FREE, personal Netscape Mail account today at 
>http://webmail.netscape.com/
>
>
>To change your membership options, refer to:
>http://www.sys-con.com/java/list.cfm
>


Is your boss reading your email? ....Probably
Keep your messages private by using Lycos Mail.
Sign up today at http://mail.lycos.com

To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm

Reply via email to