i have a table of users table of organizations i am sorting users by last name and outputting the organization they belong to. there are only 1,000 records in users but it takes about 25 seconds to sort by last name output. is this normal, will indexing make this faster? can someone give me an example of indexing this. using - @user = User.find(:all).sort_by(&:lname) i would like to sort on downcase of last name as well. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 rashantha wrote: | i have a table of users | | table of organizations | | i am sorting users by last name and outputting the organization they | belong to. | | there are only 1,000 records in users but it takes about 25 seconds to | sort by last name output. | | is this normal, will indexing make this faster? Yes, indexing will make it faster. A general overview on indexes: http://www.odetocode.com/Articles/70.aspx More specific information should be part of your RDMBS''s documentation. - -- Phillip Gawlowski Twitter: twitter.com/cynicalryan Make it right before you make it faster. ~ - The Elements of Programming Style (Kernighan & Plaugher) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkf+ZdUACgkQbtAgaoJTgL+dRgCeJORBDmt06q0/G9WLFCY7L+im 8VAAniCX1Ya+SfF8cDBvDUms8khY9rv+ =7aWA -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
http://membres.lycos.fr/ccpfordz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Indexing with a call like this:> @user = User.find(:all).sort_by(&:lname)Will do no good. User.find(:all) is the db call, the sort_by is a method of enumerable. So your app grabs all Users then does an enumerable sort on it. Much more efficient to have the database order it. @users = User.find(:all, :order => "lname asc") if you had an index on user.lname THEN indexing would make a difference. - Richard On Apr 10, 12:01 pm, rashantha <rashan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> i have a table of users > > table of organizations > > i am sorting users by last name and outputting the organization they > belong to. > > there are only 1,000 records in users but it takes about 25 seconds to > sort by last name output. > > is this normal, will indexing make this faster? > > can someone give me an example of indexing this. > > using - @user = User.find(:all).sort_by(&:lname) > > i would like to sort on downcase of last name as well.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---