rails/rails — pull request #12137 by lann (2013-09-04 23:49:35+00:00)
Title: 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.