Ruby on Rails Wednesday, June 6, 2012

Robert Walker wrote in post #1063410:
> orders = Order.order('lower(name)')
> Order Load (0.5ms) SELECT "orders".* FROM "orders" ORDER BY
> lower(name)

Keep in mind that the above will force the database to perform a
sequential scan of the table even if the column you're ordering by is
indexed. Which means that if you have performance issues you may need to
create a case-insensitive index on the column. I'll leave that as an
exercise for you on how to set that up in whatever database you are
using.

--
Posted via http://www.ruby-forum.com/.

--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment