MongoDB Documentation, Release 3.0.4 { zipcode: 1 } { zipcode: 1, u_id: 1 } { zipcode: 1, u_id: 1, c_date: 1 } How mongos Handles Query Modifiers If the result of the query is not sorted, the mongos instance opens a result cursor that “round robins” results from all cursors on the shards. Changed in version 2.0.5: In versions prior to 2.0.5, the mongos exhausted each cursor, one by one. If the query specifies sorted results using the sort() cursor method, the mongos instance passes the $orderby option to the shards. The primary shard for the database receives and performs a merge sort for all results before returning the data to the client via the mongos . If the query limits the size of the result set using the limit() cursor method, the mongos instance passes that limit to the shards and then re-applies the limit to the result before returning the result to the client. If the query specifies a number of records to skip using the skip() cursor method, the mongos cannot pass the skip to the shards, but rather retrieves unskipped results from the shards and skips the appropriate number of documents when assembling the complete result. However, when used in conjunction with a limit() , the mongos will pass the limit plus the value of the skip() to the shards to improve the efficiency of these operations. To detect if the MongoDB instance that your client is connected to is mongos , use the isMaster command. When a client connects to a mongos , isMaster returns a document with a msg field that holds the string isdbgrid . For example: If the application is instead connected to a mongod , the returned document does not include the isdbgrid string. In general, operations in a sharded environment are either: For best performance, use targeted operations whenever possible. While some operations must broadcast to all shards, you can ensure MongoDB uses targeted operations whenever possible by always including the shard key. Broadcast Operations mongos instances broadcast queries to all shards for the collection unless the mongos can determine which shard or subset of shards stores this data. Multi-update operations are always broadcast operations. The remove() operation is always a broadcast operation, unless the operation specifies the shard key in full. 10.2. Sharding Concepts 679 { "ismaster" : true , "msg" : "isdbgrid", "maxBsonObjectSize" : 16777216, "ok" : 1 } Detect Connections to mongos Instances Broadcast Operations and Targeted Operations • Broadcast to all shards in the cluster that hold documents in a collection • Targeted at a single shard or a limited group of shards, based on the shard key