[SERVER-13007] Query plan cache key not unique to query shape Created: 03/Mar/14  Updated: 11/Jul/16  Resolved: 05/Mar/14

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.6.0-rc0
Fix Version/s: 2.6.0-rc1

Type: Bug Priority: Major - P3
Reporter: J Rassi Assignee: Benety Goh
Resolution: Done Votes: 0
Labels: 26qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-17158 sort component of internal plan cache... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

The query shape serialization mechanism will map distinct query shapes to the same plan cache key. This can cause cache thrashing for the plan cache.

The encoding of plan cache keys for queries needs to (1) group lists, (2) perform escaping, and (3/4) delimit the query/sort/projection sections. See examples below.

// 1.
db.foo.find({$or:[{a:1},{b:1},{c:1}],d:1}) // plan cache key = anoreqaeqbeqceqd
db.foo.find({$or:[{a:1},{b:1}],c:1,d:1})   // plan cache key = anoreqaeqbeqceqd
 
// 2.
db.foo.find({a:1,b:1,c:1}) // plan cache key = aneqaeqbeqc
db.foo.find({a:1,beqc:1})  // plan cache key = aneqaeqbeqc 
 
// 3.
db.foo.find({a:1},{a:NumberInt(1)}) // plan cache key = eqap1a
db.foo.find({ap1a:1})               // plan cache key = eqap1a
 
// 4.
db.foo.find({a:1}).sort({b:1}) // plan cache key = eqaab
db.foo.find({aab:1})           // plan cache key = eqaab



 Comments   
Comment by Githook User [ 05/Mar/14 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-13007 added delimiters to plan cache key
Branch: master
https://github.com/mongodb/mongo/commit/aa02cde1baf6bdb7840ac007f0a5603026409b9e

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