|
The following code will execute a COLLSCAN.
db.createCollection("c", { clusteredIndex: { key: { _id: 1 }, unique: true } }));
|
db.c.createIndex({ a: 1 });
|
db.c.insert({ b: "foo", a: 1, c: 2 });
|
db.c.explain().find({ $or: [{ _id: 123 }, { a: 5 }] }).finish();
|
However, a better plan would be a OR stage with a CLUSTERED_IXSCAN and a IXSCAN stage. Currently, CLUSTERED_IXSCAN plans are not considered when we subplan the children of $or queries. We only try IXSCAN for the children and miss out on better plans. This will also address the bug in SERVER-61259. If we can support CLUSTERED_IXSCAN in the children of $or queries then we can support $text queries under $or, since we will not need to fallback on a collection scan.
|