-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: 4.0.0
-
Component/s: Querying
-
None
-
Query Execution
There are quite a few situations in which {$limit: 0} would be useful, for instance, currently in the BI-Connector we use $collStats to inject a single document when we need to pushdown a subquery that needs exactly one projected result out.
However, $collStats has some issues, and we think $facet might be a better choice. But in this case we would prefer {$limit: 0} to {$limit: 1}, since we literally don't care about the result, so for example:
select a from foo inner join (select "hello")
We would like to push down the subquery select "hello" as:
{$facet: {out: [{$limit: 0}]}} {$project: {'hello': 'hello', '_id': 0}}
At some future point this could even be a optimized to not look at any documents (currently on a collection of 100K docs, {$limit: 1} will look at 853 of them in a $facet on server 4.0), but for now, simply changing the error condition to be negative from non-positive would be an improvement.
- related to
-
SERVER-39108 Make $limit accept 0 for all documents to be passed
- Closed