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

Add ability to produce covered plans when shard key is a subfield of a provided/covered field

    XMLWordPrintable

Details

    • Improvement
    • Status: Backlog
    • Major - P3
    • Resolution: Unresolved
    • None
    • None
    • Querying
    • None
    • Fully Compatible

    Description

      When the shard key is something like {"_id.a": 1, "_id.b": 1}, we technically have enough information from the _id index to perform shard filtering. We are not currently prepared to do so though.

      Adding support for this would likely involve changing IndexScanNode::hasField to report that it "has" a field if the index includes a prefix of that field (subject to some multi key checks). After that, we would likely have to modify the shard filtering logic to be prepared to have to search for the field it's looking for within another field (things didn't "just work" after the above change in a POC).

      See the attached repro.js , which also requires this brief patch to the shell:

      diff --git a/src/mongo/shell/shardingtest.js b/src/mongo/shell/shardingtest.js
      index 4dd72ef..30d066b 100644
      --- a/src/mongo/shell/shardingtest.js
      +++ b/src/mongo/shell/shardingtest.js
      @@ -656,7 +656,7 @@ var ShardingTest = function(params) {
               return shards;
           };
       
      -    this.shardColl = function(collName, key, split, move, dbName, waitForDelete) {
      +    this.shardColl = function({collName, key, split, move, dbName, waitForDelete}) {
               split = (split != false ? (split || key) : split);
               move = (split != false && move != false ? (move || split) : false);
      

      Attachments

        Activity

          People

            backlog-query-optimization Backlog - Query Optimization
            charlie.swanson@mongodb.com Charlie Swanson
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated: