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

Take the shard key into accout when choosing an index for distinct scan

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization

      In getDistinctNodeIndex(), we currently only look at the projection when choosing an index for a hand-crafted distinct scan. We should also take into account the shard key if shard filtering is requested. For an example, consider distinct("notShardKey") with the indexes notShardKey_1 and notShardKey_1_shardKey_1. The current heuristic picks the first index, forcing us to redundantly fetch. Note also that for $group queries, the shard key and the projection might not have any common fields, and we should only consider the query covered if it can cover both of them.

            Assignee:
            Unassigned Unassigned
            Reporter:
            henri.nikku@mongodb.com Henri Nikku
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: