rails/rails — pull request #7270 by beerlington (2012-08-05 15:42:07+00:00)
Title: Changing AR:CollectionAssociation#empty? to use #exists?

COUNT(*) queries can be slow in PostgreSQL, #exists? avoids this by selecting a single record. @jonleighton suggested in issue #3179 that #empty? should be patched to use #exists? for the same benefit. I couldn't think of a great way to test it since the external behavior is not changing. If anyone has any suggestions for tests though, I would be more than happy to add them.