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

Improve shard targeting for $search

    • Query Integration

      At the time of writing, when $search is executed in a sharded cluster, mongos will perform a scatter-gather against all shards in the cluster. This behavior isn't problematic from a correctness point of view, however, if the cluster has many shards, this could potentially become a bottleneck for performance, as we need to open one (or even two, in the case of SEARCH_META) cursor(s) against each shard to answer the query. 

      Now, imagine that the $search query (or a $match stage that immediately follows it, since $search must be the first stage in a pipeline) has a predicate that covers the shard key. This information could be used to target a subset of shards (as is done for $match stages today), thus reducing the number of cursors that must be open to answer the $search query.

      This ticket tracks the work to try and extract $search or $search + $match filter predicates against the shard key and use it to improve shard targeting for $search. This might be tricky for a number of reasons:

      • It's not clear whether syncing data between mongods and mongots will be impacted by this.
      • Then, it's not clear whether the idLookup portion of $search will be resilient to any chunk migrations (today, this shouldn't be an issue because we will have a cursor open on every shard). 

            Assignee:
            backlog-query-integration [DO NOT USE] Backlog - Query Integration
            Reporter:
            mihai.andrei@mongodb.com Mihai Andrei
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated: