3 ms·
I'm not sure what a filesort refers to here, but there are absolutely cases where :order can cause performance problems. If there is no index on the ordered fie
by rezonant 2y ago
I'm not sure what a filesort refers to here, but there are absolutely cases where :order can cause performance problems. If there is no index on the ordered field, you have to remember that the order applies first (ie before you filter the results) even though you might have written it last in your ActiveRecord chain.
However, the amount of times you want to order a subset of records independent of the complete set is quite rare, as almost always you are doing some kind of paged fetch, and it makes no sense to use an indeterminate database ordering, even if you are just ordering by primary key (which is always indexed in ActiveRecord)