[SERVER-27915] Make $group with $addToSet accumulator use DISTINCT_SCAN when applicable Created: 03/Feb/17  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Aggregation Framework, Querying
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: David Storch Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 3
Labels: QFB, asya, tpcc
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-25899 Make the distinct command always exec... Backlog
Related
related to SERVER-9507 Optimize $sort+$group+$first pipeline... Closed
is related to SERVER-2130 Ability to use Limit() with Distinct() Backlog
is related to SERVER-37715 Use DISTINCT_SCAN for $unwind-$group ... Backlog
Assigned Teams:
Query Optimization
Sprint: Query 2017-02-13, Query 2017-03-27, Query 2017-04-17
Participants:
Linked BF Score: 0

 Comments   
Comment by Ana Meza [ 21/Apr/22 ]

Yes, that is the case, this SERVER ticket was closed when PM-941 was closed

james.wahlin@mongodb.com I tagged you on the meeting notes where that decision was made

Do you want to push this SERVER ticket to "Needs Triage" or Leave it on the Backlog?

Comment by Asya Kamsky [ 06/Apr/22 ]

reopening for re-triage (or to get a comment as to why it was closed)

Comment by David Storch [ 23/Oct/18 ]

$group with $first (or with no accumulators) using DISTINCT_SCAN was implemented inĀ SERVER-9507. $group with $last using DISTINCT_SCAN is now tracked by related ticketĀ SERVER-37304. Therefore, I'm narrowing the scope of this ticket to be specifically about the $addToSet case that asya mentions above.

Comment by Asya Kamsky [ 09/Oct/18 ]

Ways of getting distinct values of "field" in aggregation:

{$group:{_id:"$field"}}
{$group:{_id:null, f:{$addToSet:"$field"}}}

Comment by David Storch [ 22/May/18 ]

I would say that this is a superset of SERVER-9507. There are multiple ways to express distinct-like queries in aggregation:

  1. $group with the $addToSet accumulator.
  2. $sort followed by $group with a $first/$last accumulator.

SERVER-9507 specifically covers #2, whereas this ticket covers both scenarios. Once SERVER-9507 is implemented, the scope if this ticket should be narrowed.

Comment by Ian Whalen (Inactive) [ 21/May/18 ]

david.storch to consider whether this is a dupe/related to the Stitch work around sort/group first.

Generated at Thu Feb 08 04:16:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.