[SERVER-8135] Unused index-boundaries on multikey Created: 10/Jan/13  Updated: 05/Jun/13  Resolved: 21/Jan/13

Status: Closed
Project: Core Server
Component/s: Index Maintenance, Querying
Affects Version/s: 2.2.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Ulrik Mikaelsson Assignee: Aaron Staple
Resolution: Duplicate Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu 12.04, 12.10


Issue Links:
Duplicate
duplicates SERVER-4180 Allow multiple constraints (on same f... Closed
Operating System: ALL
Steps To Reproduce:

Create a collection with documents having a ISODate-column in the root document, and a collection of embedded documents with some criteria in each of the embedded document, and try to perform a query including both a range of dates, and a value for the embedded field.

Participants:

 Description   

Given the index
{
"v" : 1,
"key" :

{ "pricings.parent_id" : 1, "start_at" : 1 }

,
"ns" : "accounts.calls",
"name" : "pricings.parent_id_1_start_at_1"
}

The query
{
"start_at":

{ "$gte": ISODate("2012-10-15"), "$lt": ISODate("2012-10-15 08:00") }

,
"pricings.parent_id": 4
}
fails to use the upper bounds for start_at.

The explain() is;
{
"cursor" : "BtreeCursor pricings.parent_id_1_start_at_1",
"isMultiKey" : true,
"n" : 2526,
"nscannedObjects" : 349468,
"nscanned" : 349468,
"nscannedObjectsAllPlans" : 349468,
"nscannedAllPlans" : 349468,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 550,
"indexBounds" :

{ "pricings.parent_id" : [ [4,4] ], "start_at" : [ [ ISODate("2012-10-15T00:00:00Z"), ISODate("292278995-01--2147483647T07:12:56.808Z") ] ] }

,
"server" : "onatopp:27017"
}



 Comments   
Comment by Henrique Nunes [ 05/Jun/13 ]

In case someone ends up here like I do, here's some additional info on how to use the above mentioned $min/$max technique with Pymongo to work around this issue:

https://groups.google.com/forum/?fromgroups#!topic/mongodb-user/cw82dRPX2hE
https://groups.google.com/forum/?fromgroups#!searchin/mongodb-user/How$20do$20I$20use$20cursor.min$20$2F$20cursor.max$20with$20Pymongo$3F/mongodb-user/MvwPermpgws/FqrZb80PyvcJ
https://groups.google.com/forum/?fromgroups#!searchin/mongodb-user/pymongo$3A$20cursor.next()$20works$20fine$2C$20cursor.count()$20fails/mongodb-user/hhldoKg-ius/PsQtrkDOf7MJ

Comment by Aaron Staple [ 21/Jan/13 ]

Hi Ulrik - I'm going to resolve this as a duplicate of SERVER-4180. Please feel free to reopen if you have further questions.

Comment by Aaron Staple [ 15/Jan/13 ]

Hi Ulrik,

There is some background on this issue here:
<https://groups.google.com/forum/#!msg/mongodb-user/oxL8wuVdITA/uWJHVbMd_-8J>

Until SERVER-6050 is implemented, our recommendation is to make your start_at field an array and convert your query to

{
"start_at": { "$elemMatch":

{ "$gte": ISODate("2012-10-15"), "$lt": ISODate("2012-10-15 08:00") }

},
"pricings.parent_id": 4
}

or use the min / max functions as described in the the above link.

Let us know if you have any questions.

Comment by Ulrik Mikaelsson [ 10/Jan/13 ]

Seems to be related to SERVER-4180, which was closed without the relevant patch being applied.

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