Rails: weird behavior when getting last record while ordering

ActiveRecord is optimizing the SQL statement for you. This

Participation.order(created_at: :desc).last

returns the same result as

Participation.order(created_at: :asc).first

But the latter statement is more efficient because it has to traverse fewer rows, so Rails generates SQL as if you had written it that way.