Skip to content

Commit 96860e5

Browse files
committed
DOCS-617 edit write-concern note and edit the shard section in read-operations
1 parent 4b1434f commit 96860e5

File tree

3 files changed

+85
-68
lines changed

3 files changed

+85
-68
lines changed

draft/core/read-operations.txt

Lines changed: 54 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,14 @@ MongoDB creates a query plan as follows:
324324

325325
To evaluate the optimizer's choice of query plan, run the query with
326326
the :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

361360
For 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

365381
Aggregation
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

373387
Beginning with MongoDB version 2.1, the primary way to perform
374388
aggregation 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-
413411
Architecture
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

434433
For non-sharded collections, the :program:`mongos` locates the
435434
:term:`primary shard` for the database, and directs all operations to
436435
that :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
453452
the following resources:
454453

455454
- :ref:`An Introduction to Shard Keys <sharding-shard-key>`

draft/crud.txt

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,35 @@ CRUD and Database Operations
88

99
CRUD stands for :term:`create`, :term:`read`, :term:`update`, and
1010
:term:`delete` that form the core of most database driven
11-
applications. In MongoDB most applications interact with the database
12-
by way of a client library or :term:`driver` that provides an
13-
idiomatic interface to MongoDB for developers in the programming
14-
language of their choice. These documents approach CRUD from a very
15-
high level: the :doc:`/core/read-operations` document introduces
16-
reading from the database and related operations including
17-
aggregation, while the :doc:`/core/write-operations` document
18-
introduces a collection of insertion, updating, and deletion
19-
operations.
11+
applications.
12+
13+
14+
CRUD
15+
----
16+
17+
These documents provide an overview and examples of CRUD operations in
18+
MongoDB.
2019

2120
.. toctree::
2221
:maxdepth: 2
2322

23+
core/documents.txt
24+
applications/create.txt
25+
applications/read.txt
26+
applications/update.txt
27+
applications/delete.txt
28+
29+
Read/Write Operations
30+
---------------------
31+
32+
The :doc:`/core/read-operations` document introduces reading from the
33+
database and related operations including aggregation.
34+
35+
The :doc:`/core/write-operations` document introduces a collection of
36+
insertion, updating, and deletion operations.
37+
38+
.. toctree::
39+
:maxdepth: 2
40+
2441
core/read-operations
2542
core/write-operations
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.. note::
22

3-
All write operations in MongoDB by default are unsafe or
4-
*fire-and-forget*. See the documentation of :ref:`write concern
5-
<write-concern>` and :doc:`/applications/write-operations` for more
6-
information.
3+
In earlier versions of MongoDB, write operations by default returned
4+
immediately after issuing the write request. To revert to this
5+
behavior, set the write concern to ``0``. See the documentation of
6+
:ref:`write concern <write-concern>` and
7+
:doc:`/applications/write-operations` for more information.

0 commit comments

Comments
 (0)