[SERVER-70617] Allow use of column indexes for count queries Created: 17/Oct/22  Updated: 29/Oct/23  Resolved: 18/Nov/22

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

Type: Task Priority: Major - P3
Reporter: Ian Boros Assignee: Alyssa Clark
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-70871 Generate query solution before query ... Closed
Problem/Incident
Related
related to SERVER-52958 [SBE] Add support for the COUNT_SCAN ... Closed
related to SERVER-71485 Better naming for CanonicalQuery::isC... Closed
Backwards Compatibility: Fully Compatible
Participants:
Linked BF Score: 100

 Description   

Currently, count queries do not use SBE. This prevents any count-like query from using the column index, such asĀ 

db.order_lineitem.aggregate(
[
    {
        $match: {
            $and: [
                { "order.o_orderdate": { $gte: ISODate("1992-01-01") } },
                { "order.o_orderdate": { $lte: ISODate("1996-01-01") } },
                { l_discount: { $gte: 0.1 } },
                { l_discount: { $lte: 0.3 } }
            ],
            l_quantity: {
                $lte: 25
            }
        },
    },
    {
        $group: {
                _id: 1,
                count: {
                    $sum: 1
                }
            }
        }
    ]
) 

This ticket is to allow queries to use SBE for counts when an eligible column index is available. Doing this in a somewhat clean way will be tricky, because we have to choose the engine based on what indexes are available.



 Comments   
Comment by Githook User [ 18/Nov/22 ]

Author:

{'name': 'Alyssa Wagenmaker', 'email': 'alyssa.wagenmaker@mongodb.com', 'username': 'awagenmaker'}

Message: SERVER-70617 Allow use of SBE/column indexes for count queries
Branch: master
https://github.com/mongodb/mongo/commit/5521ad827b7eed39a7d3cc2c5e9d0a6782f49f8f

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