[SERVER-62707] Support bounding clustered collection scans for $regex op Created: 18/Jan/22  Updated: 05/Jul/23

Status: Backlog
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Daniel Gomez Ferro Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: clustered_collections
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Execution
Participants:

 Description   

We currently support bounding clustered collection scans when there's a comparison match expression on the cluster key: https://github.com/10gen/mongo/blob/fd275f66b712e0af181b53575efbe8a87f214a5e/src/mongo/db/query/planner_access.cpp#L267-L272

It should be easy to support the $regex operator when the query and collection collators match using the existing IndexBoundsBuilder. Something like this:

    IndexEntry ie{BSON("_id"_sd << 1),
                  IndexType::INDEX_BTREE,
                  IndexDescriptor::IndexVersion::kV2,
                  false,
                  {},
                  {},
                  false,
                  true,
                  CoreIndexInfo::Identifier("clustered"),
                  nullptr,
                  {},
                  params.clusteredCollectionCollator,
                  nullptr};
    OrderedIntervalList oil;
    IndexBoundsBuilder::BoundsTightness bt;
    IndexBoundsBuilder::translateRegex(regexExpr, BSON("_id"_sd << 1).firstElement(), ie, &oil, &bt);
 
    const auto& interval = oil.intervals.front(); // second interval is for regex objects, not possible in _id
 
    setMinRecord(collScan, record_id_helpers::keyForElem(interval.start, nullptr));
    setMaxRecord(collScan, record_id_helpers::keyForElem(interval.end, nullptr));



 Comments   
Comment by Xiaochen Wu [ 10/Feb/23 ]

Chatted with Chris and Michael about this. We don’t think this is important enough to schedule it in near future and we should backlog it for now. Send it back to engineering triage.

Comment by Steve Tarzia [ 15/Nov/22 ]

joe.sack@mongodb.com any guidance on the priority of this for clustered collections?

Comment by Ana Meza [ 10/Nov/22 ]

As part of the TS perf work PM-3050, the team also implemented the missing piece for PM-2556: Support clustered collections in multiplanner for all collections - So we are closing PM-2556 and sending this SERVER ticket back to the Triage queue

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