-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Optimization
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Use schema types and type inference to derive field-type constraints, convert them into index bounds, and intersect them with bounds on existing candidate scans. This will allow expressions without dedicated bounds-generation rules to have better index scans, as long as the expressions have typing support.
As we improve the type inference the bounds for more cases will improve.
If we have a collection schema such as:
{$jsonSchema: {properties: {foo: {type: 'string'}}}}
We know foo cannot be null, missing, and could avoid a FETCH.
If we have type inference on $isNumber, we could derive "amount is number", and produce better index bounds excluding null/missing.
{ $match: { tenantId: "tenant-42", $expr: {$isNumber: "$amount"} } }