[SERVER-16228] Simple query on _id with $eq should use IDHACK Created: 18/Nov/14  Updated: 10/Dec/14  Resolved: 18/Nov/14

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

Type: Improvement Priority: Minor - P4
Reporter: Jonathan Abrahams Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: 28qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

A simple equality query against _id results in IDHACK. When the $eq operator is supplied, the equivalent query uses IXSCAN.

db.simpleid.find({ "_id" : 1 }).explain()
db.simpleid.find({ "_id" : { "$eq" : 1 } }).explain()

Other equivalent queries, which may not be considered simple, also use IXSCAN:

db.simpleid.find({ $or : [{ _id : { $eq : 1 } }] }).explain()
db.simpleid.find({ $and : [{ _id : { $all : [1] } }] }).explain()


Generated at Thu Feb 08 03:40:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.