@@ -324,15 +324,14 @@ MongoDB creates a query plan as follows:
324324
325325To evaluate the optimizer's choice of query plan, run the query with
326326the :method:`explain() <cursor.explain()>` method and the
327- :method:`hint() <cursor.hint()>` method appended. Instead of returning
328- query results, this returns statistics about how the query runs. For
329- example:
327+ :method:`hint() <cursor.hint()>` method appended, as in the following:
330328
331329.. code-block:: javascript
332330
333331 db.inventory.find( { type: 'food' } ).explain().hint()
334332
335- For details on the output, see the :method:`explain()
333+ This returns the statistics regarding the execution of the query. For a
334+ detailed explanation on the output, see the :method:`explain()
336335<cursor.explain()>` method documentation.
337336
338337.. note::
@@ -360,27 +359,43 @@ parallel query operation.
360359
361360For more information, refer to :doc:`/applications/indexes`.
362361
362+ Query Operators that Cannot Use Indexes
363+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
364+
365+ Some query operators cannot take advantage of indexes and require a
366+ collection scan. When using these operators, you can narrow the
367+ documents scanned by combining the operator with another operator that
368+ does use an index.
369+
370+ Operators that cannot use indexes include the following:
371+
372+ - :operator:`$nin`
373+
374+ - :operator:`$ne`
375+
376+ .. TODO Regular expressions queries also do not use an index except when used with anchors.
377+ .. TODO :method:`cursor.skip()` can cause paginating large numbers of docs
378+
363379.. _read-operations-aggregation:
364380
365381Aggregation
366382~~~~~~~~~~~
367383
368- When you run a query using aggregation, MongoDB performs summary,
369- grouping, or other operations on data before returning results. When you
370- run a query without aggregation, you retrieve data as it's stored in the
371- database; when you run with aggregation, you retrieve reframed data.
384+ With aggregation, MongoDB performs summary, grouping, or other
385+ operations on data before returning the results.
372386
373387Beginning with MongoDB version 2.1, the primary way to perform
374388aggregation is through the aggregation framework, which processes data
375- through pipelines and returns data as a document stream specific to the
376- aggregation process.
389+ through pipelines and returns the data as a document stream specific to
390+ the aggregation process.
377391
378- For more information on the aggregation framework, including
379- descriptions of operators, see see :doc:`/applications/aggregation`.
392+ The order of aggregation operators can affect the performance of the
393+ query. For more information on the aggregation framework, including the
394+ descriptions of the operators and the optimization of performance, see
395+ :doc:`/applications/aggregation`.
380396
381- In addition to the operators used by the aggregation framework, you can
382- use the following aggregation operators. For documentation on each
383- operator, click the operator name:
397+ Additionally, MongoDB supplements the aggregation framework with the
398+ following methods and commands:
384399
385400- :method:`count() <cursor.count()>`
386401
@@ -393,23 +408,6 @@ operator, click the operator name:
393408.. index:: read operation; architecture
394409.. _read-operations-architecture:
395410
396- Query Operators that Cannot Use Indexes
397- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
398-
399- Some query operators cannot take advantage of indexes and require a
400- collection scan. When using these operators you can narrow the documents
401- scanned by combining the operator with another operator that does use an
402- index.
403-
404- Operators that cannot use indexes include the following:
405-
406- - :operator:`$nin`
407-
408- - :operator:`$ne`
409-
410- .. TODO Regular expressions queries also do not use an index except when used with anchors.
411- .. TODO :method:`cursor.skip()` can cause paginating large numbers of docs
412-
413411Architecture
414412------------
415413
@@ -422,34 +420,35 @@ Connection Pooling
422420
423421.. TODO
424422
425- Shard Clusters
426- ~~~~~~~~~~~~~~
423+ Sharded Clusters
424+ ~~~~~~~~~~~~~~~~
427425
428- Issue all read operations to a sharded cluster to one of the
429- :program:`mongos` instances associated with the cluster. From the
430- perspective of the application there is no difference between read
431- operations to MongoDB sharded clusters and read operations to
432- standalone instances and replica sets.
426+ Sharded clusters allows for the distribution of the collection data
427+ across multiple nodes. With a sharded cluster, you issue all read
428+ operations to one of the :program:`mongos` instances associated with
429+ the cluster. From the perspective of the application there is no
430+ difference between read operations to the MongoDB sharded cluster and
431+ read operations to standalone instances and replica sets.
433432
434433For non-sharded collections, the :program:`mongos` locates the
435434:term:`primary shard` for the database, and directs all operations to
436435that :program:`mongod` instance. For sharded collections, the
437- :program:`mongos` must determine which :term:`shard` may have
438- documents that could match the query using the :term:`shard
439- key` . Then, the :program:`mongos` can direct the query to the relevant
440- members and merge all reseults .
441-
442- If the query operation includes either the shard key, *or* a prefix of
443- the shard key, the :program:`mongos` may be able to target the query
444- to a smaller subset of the shards. In other cases, the
445- :program:`mongos` must query *all* shards in the cluster for
446- results. For clusters with a small number of shards, non-targeted
447- queries may perform acceptabily, but with more shards these
448- non-targeted queries, are inefficient and not pratical for routine
449- operations. When choosing a shard key, always pick a key that allows
450- you to minimize or eleminate non-targeted queries .
451-
452- For more information on read operations in sharded systems , consider
436+ :program:`mongos` uses the :term:`shard key` to determine which
437+ :term:`shard` or shards contains the documents that could match the
438+ query . Then, the :program:`mongos` directs the query to the relevant
439+ shards and merges the results .
440+
441+ Choosing the appropriate shard key can improve the performance of the
442+ query. If the query operation includes either the shard key, *or* a
443+ prefix of the shard key, the :program:`mongos` may be able to target
444+ the query to a smaller subset of the shards. Otherwise, the
445+ :program:`mongos` performs non-targeted queries; i.e., :program:`mongos`
446+ must query *all* shards in the cluster for the results. For clusters
447+ with a small number of shards, the performance of non-targeted queries
448+ may be acceptable. But, with more shards, non-targeted queries become
449+ inefficient and impractical for routine operations .
450+
451+ For more information on read operations in sharded clusters , consider
453452the following resources:
454453
455454- :ref:`An Introduction to Shard Keys <sharding-shard-key>`
0 commit comments