[SERVER-12499] Unable to force predicate evaluation order with new query framework Created: 27/Jan/14  Updated: 21/Oct/15  Resolved: 21/Oct/15

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

Type: Improvement Priority: Major - P3
Reporter: Daniel Pasette (Inactive) Assignee: David Storch
Resolution: Duplicate Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File server-12499.js    
Issue Links:
Depends
Duplicate
duplicates SERVER-16042 Optimise $all/$and to select smallest... Closed
is duplicated by SERVER-12865 MultiKey Cardinality issues in index ... Closed
Backwards Compatibility: Minor Change
Participants:

 Description   

In version 2.4 and before, predicate order was significant to the query optimizer. Thus if selectivity of a query predicate was known, it could influence the planner.

Now, query plans are normalized into a generic query execution tree and re-ordered, so predicate evaluation order can be "surprising" based on the sort order of the actual data being queried for. There is no way to override this behavior because in both cases, the optimizer chooses the correct "plan" but can't choose the correct predicate to evaluate first.

Attaching a test which if run in 2.4 and then 2.5.5 shows the change in behavior. One example uses a hash_merge of 3 $and predicates on a single multi-key index, one with a very low cardinality.

The second example shows a 2 predicate $and query where the optimizer chooses the wrong query predicate.



 Comments   
Comment by David Storch [ 21/Oct/15 ]

This issue has been fixed under SERVER-16042. Resolving as a duplicate.

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