Skip to content

Commit 5d06340

Browse files
johnnyshieldscomandeo-mongop
authored
MONGOID-5005 - .sum, .count, and similar aggregables now ignore sort if not limiting/skipping (#5049)
* MONGOID-5005 - .sum, .count, and similar aggregables should ignore sort if not limiting/skipping * release note Co-authored-by: shields <[email protected]> Co-authored-by: Dmitry Rybakov <[email protected]> Co-authored-by: Oleg Pudeyev <[email protected]>
1 parent 4d819bb commit 5d06340

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

source/release-notes/mongoid-7.4.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,17 @@ Mongoid 7.3 behavior:
151151

152152
Note that the alias expansion for top-level fields has already been
153153
done by Mongoid 7.3.
154+
155+
156+
``count``, ``sum``, ``avg``, ``min``, ``max`` Ignore Sort If Not Limiting/Skipping
157+
----------------------------------------------------------------------------------
158+
159+
The ``count``, ``sum``, ``avg``, ``min`` and ``max`` methods now omit the
160+
sort stage from the generated aggregation pipeline if no skip or limit
161+
is specified, because the results aren't affected by the sort order.
162+
Example call that will now omit the sort stage and would potentially use
163+
an index where it wouldn't before:
164+
165+
.. code-block:: ruby
166+
167+
Band.desc(:name).count

0 commit comments

Comments
 (0)