@@ -78,22 +78,29 @@ collection.
78
78
{ zipcode: 1, u_id: 1 }
79
79
{ zipcode: 1, u_id: 1, c_date: 1 }
80
80
81
- How ``mongos`` Establishes a Cursor on Targeted Shards
82
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
81
+ How ``mongos`` Handles Query Flags
82
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
83
+
84
+ If the result of the query is unsorted, the :program:`mongos` instance opens
85
+ a result cursor that "round robins" results from all cursors on the
86
+ shards.
83
87
84
- When the first batch of results returns from the cursors, the
85
- :program:`mongos` instance does one of the following:
88
+ .. versionChanged::2.0.5
89
+ In versions prior to 2.0.5, the :program:`mongos` exhausted each cursor, one by one.
86
90
87
- - For query with sorted results (i.e. using :method:`cursor.sort()`) the
88
- :program:`mongos` instance performs a merge sort of all queries.
91
+ If the result is supposed to be sorted (i.e. the query used
92
+ :method:`cursor.sort()`), the :program:`mongos` instance passes the `sort()` flag down to
93
+ the targeted shards, and performs a merge sort of the results.
89
94
90
- - For a query with unsorted results, the :program:`mongos` instance
91
- returns a result cursor that "round robins" results from all cursors
92
- on the shards.
95
+ If the query used :method:`cursor.limit()`, the :program:`mongos` instance passes that limit
96
+ down to the shards and then re-applies it to the complete result.
93
97
94
- .. versionchanged:: 2.0.5
95
- Before 2.0.5, the :program:`mongos` exhausted each cursor,
96
- one by one.
98
+ If the query used :method:`cursor.skip()`, the :program:`mongos` instance cannot pass it
99
+ down to the shards since it cannot know in advance how much of the
100
+ skip will be filled by each individual result. The :program:`mongos` instance
101
+ therefore does *not* pass the `skip()` value down, but instead passes a
102
+ `limit()` value of `(skip+limit)` down to the shards, and then performs
103
+ the actual skip when assembling the complete result.
97
104
98
105
Detect Connections to :program:`mongos` Instances
99
106
-------------------------------------------------
0 commit comments