From d7a7a050e103def759d1e5694e5aaa35b1d03cd1 Mon Sep 17 00:00:00 2001 From: Eugene Gilburg Date: Sun, 27 Oct 2013 23:58:23 -0700 Subject: Optimize none? and one? relation query methods to use LIMIT and COUNT. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use SQL COUNT and LIMIT 1 queries for none? and one? methods if no block or limit is given, instead of loading the entire collection to memory. The any? and many? methods already follow this behavior. [Eugene Gilburg & Rafael Mendonça França] --- activerecord/lib/active_record/null_relation.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'activerecord/lib/active_record/null_relation.rb') diff --git a/activerecord/lib/active_record/null_relation.rb b/activerecord/lib/active_record/null_relation.rb index 63ca29305d..fa6eaa7e64 100644 --- a/activerecord/lib/active_record/null_relation.rb +++ b/activerecord/lib/active_record/null_relation.rb @@ -30,10 +30,18 @@ module ActiveRecord true end + def none? + true + end + def any? false end + def one? + false + end + def many? false end -- cgit v1.2.3