rails/rails — pull request #16400 by bogdan (2014-08-05 11:42:56+00:00)
Title: Always use SQL limit in Relation#last when limit argument given

Using `Relation#last` causes entire relation to be loaded into memory.
In most cases it is unacceptable:

``` ruby
Topic.order(:created_at).last(2)
# => SELECT * FROM topics ORDER BY created_at
```

We can still use `reverse_order` to let SQL do heavy lifting (AR is quite bad at that).

``` ruby
Topic.order(:created_at).last(2)
# => SELECT * FROM topics ORDER BY created_at DESC LIMIT 2
```

Unfortunately back to 2011 in this commit 5f5527c7 it wasn't done. And 2 x unfortunately this commit added 2 tests that need to be modified now.

@dmathieu do you still remember something about it?