aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/CHANGELOG.md
diff options
context:
space:
mode:
authorEugene Gilburg <eugene.gilburg@gmail.com>2013-10-27 23:58:23 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-02-12 17:40:59 -0200
commitd7a7a050e103def759d1e5694e5aaa35b1d03cd1 (patch)
treeda6965c7c8404d1b884b95b13dc06dd3f741bfde /activerecord/CHANGELOG.md
parent8d0fe8047a3c630d29224688ecfa4f4b26cb238a (diff)
downloadrails-d7a7a050e103def759d1e5694e5aaa35b1d03cd1.tar.gz
rails-d7a7a050e103def759d1e5694e5aaa35b1d03cd1.tar.bz2
rails-d7a7a050e103def759d1e5694e5aaa35b1d03cd1.zip
Optimize none? and one? relation query methods to use LIMIT and COUNT.
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]
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r--activerecord/CHANGELOG.md22
1 files changed, 22 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 16f3f47d29..e1cace7d88 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,3 +1,25 @@
+* 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.
+ This applies to relations (e.g. `User.all`) as well as associations (e.g. `account.users`)
+
+ # Before:
+
+ users.none?
+ # SELECT "users".* FROM "users"
+
+ users.one?
+ # SELECT "users".* FROM "users"
+
+ # After:
+
+ users.none?
+ # SELECT 1 AS one FROM "users" LIMIT 1
+
+ users.one?
+ # SELECT COUNT(*) FROM "users"
+
+ *Eugene Gilburg*
+
* Allow `:precision` option for time type columns.
*Ryuta Kamizono*