[SERVER-52958] [SBE] Add support for the COUNT_SCAN stage to the SBE stage builders Created: 20/Nov/20  Updated: 29/Oct/23  Resolved: 02/Jun/23

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 7.1.0-rc0

Type: Task Priority: Major - P3
Reporter: Drew Paroski Assignee: Zixuan Zhuang
Resolution: Fixed Votes: 0
Labels: auto-reverted, qexec-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-77203 Classic Group should not use DoubleDo... In Code Review
is depended on by SERVER-76815 Parameterize COUNT_SCAN index keys in... Closed
is depended on by SERVER-77973 Do not gate COUNT_SCAN in SBE by feat... Closed
Duplicate
duplicates SERVER-51823 Use classic engine to evaluate querie... Closed
Problem/Incident
Related
is related to SERVER-51655 Investigate sys-perf benchmark perfor... Closed
is related to SERVER-70617 Allow use of column indexes for count... Closed
Assigned Teams:
Query Execution
Backwards Compatibility: Fully Compatible
Sprint: QE 2023-05-15, QE 2023-05-29, QE 2023-06-12
Participants:
Linked BF Score: 1

 Description   

When I tried to run the "bestbuy_agg_query_comparison.js" benchmark (fromĀ https://github.com/10gen/workloads) with useAgg=true and with SBE mode enabled, the benchmark failed with an error message saying "Can't build exec tree for node: COUNT".

I've created a simple example that reproduces the failure:

> db.adminCommand({setParameter:1, internalQueryEnableSlotBasedExecutionEngine:true});
> db.c.insert({a: 1})
> db.c.createIndex({a: 1})
> db.c.aggregate([{$match: {a: 1}}, {$count: "count"}]).itcount();

The goal of this task is to implement support for the COUNT stage so that these kinds of queries work correctly when SBE mode is enabled.



 Comments   
Comment by Githook User [ 27/Jun/23 ]

Author:

{'name': 'Zixuan', 'email': 'leozzx@users.noreply.github.com', 'username': 'leozzx'}

Message: SERVER-52958 Add more perf test for COUNT SCAN (#134)
Branch: master
https://github.com/mongodb/mongo-perf/commit/d4562b5d2d941613af2424192557b10b9cc24934

Comment by Githook User [ 31/May/23 ]

Author:

{'name': 'Zixuan Zhuang', 'email': 'zixuan.zhuang@mongodb.com', 'username': 'leozzx'}

Message: SERVER-52958 Support COUNT_SCAN in SBE
Branch: master
https://github.com/mongodb/mongo/commit/5560c0329545b07a475f74a4bf7501881b9eed07

Comment by xgen-buildbaron-user [ 31/May/23 ]

Ticket re-opened due to revert. replica_sets_multi_stmt_txn_jscore_passthrough began a consistent failure of jstests/core/index/index_count_scan.js

Comment by Githook User [ 31/May/23 ]

Author:

{'name': 'auto-revert-processor', 'email': 'dev-prod-dag@mongodb.com', 'username': ''}

Message: Revert "SERVER-52958 Support COUNT_SCAN in SBE"

This reverts commit 0bc76a695b1128d34cc506e903b03bc325a25398.
Branch: master
https://github.com/mongodb/mongo/commit/55d0e62ab4069a06fa47de6eec8b3b24faed6bf0

Comment by Githook User [ 31/May/23 ]

Author:

{'name': 'Zixuan Zhuang', 'email': 'zixuan.zhuang@mongodb.com', 'username': 'leozzx'}

Message: SERVER-52958 Support COUNT_SCAN in SBE
Branch: master
https://github.com/mongodb/mongo/commit/0bc76a695b1128d34cc506e903b03bc325a25398

Comment by Githook User [ 11/May/23 ]

Author:

{'name': 'Zixuan Zhuang', 'email': 'zixuan.zhuang@mongodb.com', 'username': 'leozzx'}

Message: SERVER-52958 Add more perf test for COUNT SCAN
Branch: zixuan/SERVER-52958_perf
https://github.com/mongodb/mongo-perf/commit/293036877c53ae332b0de91d62aaef7bbe46e81c

Comment by David Storch [ 16/Mar/23 ]

I'm re-opening this ticket for re-triage and clarified the title to indicate that this is specifically about the COUNT_SCAN QuerySolutionNode. The logic for selecting between the classic engine and SBE has changed quite a bit since this ticket was filed. Of particular relevance is SERVER-70617. The goal of SERVER-70617, as I understand it, was to allow count-like aggregation queries to run in SBE specifically in the case of columnstore indexes.

If there is no columnstore index but any of the QuerySolution trees produced by the classic QueryPlanner have a COUNT_SCAN node, then we have special logic to bail out and fall back to the classic engine. This is notable because generally we select between the classic engine and SBE at a higher level, before doing any query planning. The presence of a COUNT_SCAN node is one of the few reasons that we can bail out of SBE after getting further into the planning process.

For this reason – in addition to the more straightforward reasons that supporting more features in SBE is good for our engineering progress and often good for performance – now might be a good time to add support for COUNT_SCAN in the SBE stage builders. Note that I am not suggesting that we allow count commands to use SBE, but rather that we allow count-like aggregate commands which result in a COUNT_SCAN to use SBE.

Hopefully it will be possible to provide a performant implementation of COUNT_SCAN in SBE without adding any new concepts to the core SBE engine.

cc mihai.andrei@mongodb.com alyssa.wagenmaker@mongodb.com

Generated at Thu Feb 08 05:29:30 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.