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

Sharded $search queries should not exhaust all results on shards to generate first batch

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

      If sharded search query has in total 100,000 results, in order to populate the first user batch of 101 documents, all 100,000 results must be first retrieved from mongot, processed by the shards, then returned to mongos. The AsynchronousResultsMerger within the $mergeCursors stage is populated with all 100,000 results, but we only iterate the first 101 to fill the first batch. This makes the time to materialize the first batch quite slow for sharded search.

      The $mergeCursors stage on mongos uses the search score as the sort key, so it thinks it needs to sort all results from the shards before returning any documents. However, the results returned from shards are already sorted by search score, so mongos should really only need up to batchSize results per shard in order to generate the first batch with batchSize results (could be more depending on the merging pipeline).

            Assignee:
            Unassigned Unassigned
            Reporter:
            will.buerger@mongodb.com Will Buerger
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: