[SERVER-55065] Null queries should be covered by index where possible with current index format Created: 09/Mar/21  Updated: 29/Oct/23  Resolved: 19/Mar/21

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

Type: Bug Priority: Major - P3
Reporter: Alya Berciu Assignee: Alya Berciu
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-12869 Index null values and missing values ... Backlog
related to SERVER-18861 Queries matching null value should be... Backlog
is related to SERVER-28889 Partial index shouldn't do fetch on c... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Query Optimization 2021-03-22
Participants:
Case:

 Description   

Before changing the index format, it is only possible to cover null queries in certain conditions:

  • the index being scanned is not multikey, because indexes alone cannot distinguish between null, missing, undefined, and empty array values
  • the query is either not projecting (as in the case of either legacy or aggregation count) or the query is projecting directly only onto the _id field. This is possible because _id fields are guaranteed to be unique and present, so we can have at most one _id field set to null in the index (meaning we would always get the right value for _id from the index).

Furthermore, we can optimize counts to use two COUNT_SCANs joined by an OR stage when a single null interval is encountered (instead of just using an INDEX_SCAN with a. filter).

This branched off of https://jira.mongodb.org/browse/SERVER-18861.



 Comments   
Comment by Githook User [ 18/Mar/21 ]

Author:

{'name': 'Alya Berciu', 'email': 'alyacarina@gmail.com', 'username': 'alyacb'}

Message: SERVER-55065: Cover null queries with index where possible
Branch: master
https://github.com/mongodb/mongo/commit/54a41757d77002b015c7bceca87c59f35e5a564f

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