2014년 12월 12일 금요일

Difference in Query plan in queries with Implicit And and those with "$and".

We (parse.com) ran into this issue where the different forms of and queries pick different query plans.

We have three forms of the query in the paste 

One with $and, one a mixed $and + implicit and, the third with no $and just the implicit form.

The issue is only the implicit form of the query returns results as it uses a sane index. The other queries hit the maxScan limit. 

Can someone explain this?
I am very dumbfounded right now :(



You're using 2.4.x here, yes?   It's a flaw in 2.4 and earlier that's
been fixed in 2.6 where all queries are now converted to the same
canonical form regardless of how they were written.   This is why in
the past I've always admonished people not to use $and except in the
very rare cases it's actually necessary, because it caused the query
optimizer pains in picking the right index...



any thoughts? Ping 



Any thoughts on my response from Nov 1st?


댓글 없음:

댓글 쓰기