[SERVER-46168] Sort without predicate on non-hashed prefix fields does not use compound hashed index Created: 14/Feb/20  Updated: 29/Oct/23  Resolved: 18/Mar/20

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 4.4.0-rc0, 4.7.0

Type: Improvement Priority: Major - P3
Reporter: Arun Banala Assignee: Arun Banala
Resolution: Fixed Votes: 0
Labels: qexec-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Backport Requested:
v4.4
Sprint: Query 2020-03-23
Participants:

 Description   

If there is no query predicate, we use a different code path to do just sorting. This should also be updated to allow compound hashed indexes for sorting.



 Comments   
Comment by Githook User [ 24/Mar/20 ]

Author:

{'email': 'arun.banala@mongodb.com', 'name': 'Arun Banala', 'username': 'banarun'}

Message: SERVER-46168 Sort without predicate on non-hashed prefix fields does not use compound hashed index

(cherry picked from commit 9606514ab0a77fbe14eb9a3f607d193a50971634)
Branch: v4.4
https://github.com/mongodb/mongo/commit/1a7df047740b49c67598cd82974822020c654b3b

Comment by Githook User [ 16/Mar/20 ]

Author:

{'username': 'banarun', 'name': 'Arun Banala', 'email': 'arun.banala@mongodb.com'}

Message: SERVER-46168 Sort without predicate on non-hashed prefix fields does not use compound hashed index
Branch: master
https://github.com/mongodb/mongo/commit/9606514ab0a77fbe14eb9a3f607d193a50971634

Comment by Craig Homa [ 18/Feb/20 ]

We also want to backport this to 4.4.

Comment by Craig Homa [ 18/Feb/20 ]

Steps to reproduce from when this was a bug:

db.c.createIndex(

{a: 1, b: 'hashed'}

)

{ "createdCollectionAutomatically" : false, "numIndexesBefore" : 1, "numIndexesAfter" : 2, "commitQuorum" : 1, "ok" : 1 }

> db.c.find().sort(

{a: 1}

).explain()
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "test.c",
"indexFilterSet" : false,
"parsedQuery" : {

},
"queryHash" : "3344645B",
"planCacheKey" : "3344645B",
"winningPlan" : {
"stage" : "SORT",
"sortPattern" :

{ "a" : 1 }

,
"memLimit" : 104857600,
"type" : "simple",
"inputStage" :

{ "stage" : "COLLSCAN", "direction" : "forward" }

},
"rejectedPlans" : [ ]
},
"serverInfo" :

{ "host" : "arun", "port" : 27017, "version" : "0.0.0", "gitVersion" : "unknown" }

,
"ok" : 1
}

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