Please sign in to comment.
Make CollectionAssociation first/last with integer fetch with query
When first or last is called with an integer on an unloaded association, the entire collection is loaded. This differs surprisingly from the behavior of Relation#first/last, which translate the call into a limit query. For large collections this can make a big difference in performance. Change CollectionAssociation#fetch_first_or_last_using_find? to make this kind of call delegate to Relation.
- Loading branch information...
Showing with 11 additions and 6 deletions.