[SERVER-29445] Support additional queries with partial indexes when type is string Created: 05/Jun/17  Updated: 06/Jun/23

Status: Backlog
Project: Core Server
Component/s: Index Maintenance, Querying
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Asya Kamsky Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-20345 Support additional queries with $type... Backlog
Assigned Teams:
Query Optimization
Participants:
Case:

 Description   

If an index on a string field is defined using partialFilterExpression "$exists" or "$gt":'' then the partial index is used, however, if it's defined using "$type":"string" then the partial index is not used.

// for query
db.c.find({a:'Asya'})
// this index is used
db.c.createIndex({a:1},{partialFilterExpression:{a:{$exists:true}}})
// this index is used
db.c.createIndex({a:1},{partialFilterExpression:{a:{$gt:''}}})
// this index is *not* used
db.c.createIndex({a:1},{partialFilterExpression:{a:{$type:"string"}}})

Similar improvement to SERVER-20345 but for "string" types.


Generated at Thu Feb 08 04:20:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.