Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-29445

Support additional queries with partial indexes when type is string

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Index Maintenance, Querying
    • Labels:
      None
    • Query Optimization

      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.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            asya.kamsky@mongodb.com Asya Kamsky
            Votes:
            2 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: