aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/README.rdoc
diff options
context:
space:
mode:
authorDavid Celis <me@davidcel.is>2013-05-09 20:31:31 +0530
committerDavid Celis <me@davidcel.is>2013-06-07 10:16:59 -0700
commit4e2bec383239f9ab3493208ef3bad1f2cbea3c93 (patch)
treeaa7c08c45b9cc6ee85a3f896c0f6cf23300ef8cb /activemodel/README.rdoc
parent94725b81f5588e4b0f43222c4f142c3135941b4b (diff)
downloadrails-4e2bec383239f9ab3493208ef3bad1f2cbea3c93.tar.gz
rails-4e2bec383239f9ab3493208ef3bad1f2cbea3c93.tar.bz2
rails-4e2bec383239f9ab3493208ef3bad1f2cbea3c93.zip
ActiveRecord::Relation#blank? should `LIMIT 1`
This is an SQL improvement to ActiveRecord::Relation#blank?. Currently, it calls `to_a` on the Relation, which loads all records in the association, and calls `blank?` on the loaded Array. There are other ways, however, to check the emptiness of an association that are far more performant. `#empty?`, `#exists?` and `#any?` all attach a `LIMIT 1` to the SQL query before firing it off, which is a nice query improvement. `#blank?` should do the same! Bonus performance improvements will also happen for `#present?`, which merely calls the negation of `#blank?` Signed-off-by: David Celis <me@davidcel.is>
Diffstat (limited to 'activemodel/README.rdoc')
0 files changed, 0 insertions, 0 deletions