Operational Defect Database

BugZero found this defect 2498 days ago.

MongoDB | 377332

[SERVER-28957] Index bounds are not detected correctly

Last update date:

5/8/2017

Affected products:

MongoDB Server

Affected releases:

3.4.2

Fixed releases:

No fixed releases provided.

Description:

Info

Documents with two fields: {sort:..,x:...} Index on {sort:1,x:1} The query on "x" sorted by the sort field doesn't detect proper index bounds for x: > db.test.find({x:{$gte:1,$lte:3}}).sort({sort:1}).explain("executionStats").executionStats.executionStages.inputStage.indexBounds { "sort" : [ "[MinKey, MaxKey]" ], "x" : [ "[MinKey, MaxKey]" ] } However, adding an all-inclusive condition on "sort" into the query fixes the problem: > db.test.find({sort:{$gte:MinKey},x:{$gte:1,$lte:3}}).sort({sort:1}).explain("executionStats").executionStats.executionStages.inputStage.indexBounds { "sort" : [ "[MinKey, MaxKey]" ], "x" : [ "[1.0, 3.0]" ] }

Top User Comments

david.storch commented on Mon, 8 May 2017 17:06:50 +0000: I am closing as a duplicate of SERVER-13197. The scenarios are slightly different (this one uses a sort, the other uses a hint) but the essence is the same: when there is no predicate on the leading field of the index, the query planner is not able to constrain the index bounds of the trailing fields. There is no fundamental reason that we couldn't construct bounds for the trailing fields. However, the planner has quite a bit of index selection and plan enumeration logic which depends on differential treatment of leading versus trailing fields of a compound index. Extending the planner to generate better index bounds in cases like this one will therefore involve significant development effort from the Query Team.

Additional Resources / Links

Share:

BugZero Risk Score

Coming soon

Status

Closed

Have you been affected by this bug?

cost-cta-background

Do you know how much operational outages are costing you?

Understand the cost to your business and how BugZero can help you reduce those costs.

Discussion

Login to read and write comments.

Have you ever...

had your data corrupted from a

VMware

bug?

Search:

...