user94154
user94154

Reputation: 16574

Order of scopes in ActiveRecord/Rails queries

I'm running a lot of ActiveRecord queries in my Rails app that have quite a few named and dynamic scopes. I was wondering if there is any difference performance-wise in how those scopes are order.

For example, could Person.american.adult.find(:all) be an slower than Person.adult.american.find(:all) ?

Upvotes: 0

Views: 87

Answers (1)

mylescarrick
mylescarrick

Reputation: 1680

Nope. Have a look at your log, and you'll see that ActiveRecord is working its magic by combining them all and then (if possible) performing a single query.

Upvotes: 1

Related Questions