@@ -14,8 +14,8 @@ by overwriting the oldest documents in the collection.
14
14
Capped collections have the following behaviors:
15
15
16
16
- Capped collections guarantee preservation of the insertion order. As
17
- a result, queries do not need an index to return documents ordered
18
- by the insertion order. Without this indexing overhead, they can
17
+ a result, queries do not need an index to return documents in
18
+ insertion order. Without this indexing overhead, they can
19
19
support higher insertion throughput.
20
20
21
21
- Capped collections guarantee that insertion order is identical to the
@@ -33,7 +33,7 @@ collection. Consider the following potential uses cases for capped
33
33
collections:
34
34
35
35
- Store log information generated by high-volume systems. Inserting
36
- documents in an capped collection without an index is close to the
36
+ documents in a capped collection without an index is close to the
37
37
speed of writing log information directly to a file
38
38
system. Furthermore, the built-in *first-in-first-out* property
39
39
maintains the order of events, while managing storage use.
@@ -49,33 +49,36 @@ Recommendations and Restrictions
49
49
50
50
- You cannot shard a capped collection.
51
51
52
- - Only capped collections created after 2.2 have an ``_id`` field and
53
- indexes on the ``_id`` field. Capped collections created before 2.2
54
- do indexes on the ``_id`` by default.
52
+ - Capped collections created after 2.2 have an ``_id`` field and an
53
+ index on the ``_id`` field by default. Capped collections created
54
+ before 2.2 do not have an index on the ``_id`` field by default. If
55
+ you are using capped collections with replication prior to 2.2, you
56
+ should explicitly create an index on the ``_id`` field.
55
57
56
58
- You *can* update documents in a collection after inserting them;
57
59
*however*, these updates *cannot* cause the documents to grow. If the
58
- update operation causes the document to grow, the update operation
59
- will fail.
60
+ update operation causes the document to grow beyond their original
61
+ size, the update operation will fail.
60
62
61
63
If you plan to update documents in a capped
62
64
collection, remember to create an index to prevent update
63
65
operations that require a table scan.
64
66
65
67
- You cannot delete documents from a capped collection. To remove all
66
- records from the collection, use the :dbcommand:`emptycapped`
67
- command.
68
+ records from a capped collection, use the 'emptycapped' command. To
69
+ remove the collection entirely, use the :method:`drop()
70
+ <db.collection.drop()>` method.
68
71
69
72
.. warning::
70
73
71
74
If you have a capped collection in a :term:`replica set` outside of
72
75
the ``local`` database, before 2.2, you should create a unique
73
76
index on ``_id``. Ensure uniqueness using the ``unique: true``
74
77
option to the :method:`ensureIndex() <db.collection.ensureIndex()>`
75
- by using an :term:`ObjectId` for the ``_id`` field use the
76
- ``autoIndexId`` option to :dbcommand:`createCollection` when
77
- creating the capped collection, as in the
78
- :ref:`capped-collections-options` procedure.
78
+ method or by using an :term:`ObjectId` for the ``_id``
79
+ field. Alternately, you can use the ``autoIndexId`` option to
80
+ :dbcommand:`createCollection` when creating the capped collection,
81
+ as in the :ref:`capped-collections-options` procedure.
79
82
80
83
- Use natural ordering to retrieve the most recently inserted elements
81
84
from the collection efficiently. This is (somewhat) analogous to
0 commit comments