Skip to content

Commit 7900a0c

Browse files
author
Bob Grabar
committed
DOCS-653 rewrote top section
1 parent 957ed45 commit 7900a0c

File tree

1 file changed

+31
-42
lines changed

1 file changed

+31
-42
lines changed

draft/core/capped-collections.txt

Lines changed: 31 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,49 @@ Capped Collections
55
.. default-domain:: mongodb
66

77
:term:`Capped collections <capped collection>` are fixed-size
8-
collections that automatically overwrite their oldest entries when the
9-
fixed size is reached. Capped collections work in a way similar to
10-
circular buffers. The :term:`oplog.rs <oplog>`
11-
collection used in replication is an example of a capped collection.
8+
collections that automatically overwrite their oldest documents when new
9+
documents are inserted. Capped collections work in a way similar to
10+
circular buffers. Once a collection fills its allocated space, it makes
11+
room for new documents by deleting the oldest documents in the
12+
collection.
1213

13-
Capped collections automatically store documents in their insertion
14-
order. Once the collection's allocated space is fully used, newly added
15-
documents replace the oldest documents in the collection. The automatic
16-
replacement based on insertion order makes capped collections fast and
17-
efficient.
14+
Capped collections are particularly fast and efficient for operations,
15+
such as logging, that retrieve and delete documents based on insertion
16+
order.
1817

19-
You cannot increase the size of a document in a capped collection. You can update a
20-
document, but it must not grow in size.
18+
Capped collections have the following behaviors:
2119

22-
You cannot shard a capped collection.
23-
24-
Capped Collection Use Cases
25-
---------------------------
26-
27-
The following are scenarios in which you might want to use a capped collection:
28-
29-
- Logging
20+
- Capped collections automatically store documents in their insertion
21+
order. Therefore, no index is required to query on insertion order,
22+
and capped collections incur no indexing overhead for this property.
3023

31-
Capped collections provide a high-performance means for storing
32-
logging documents in the database. Inserting documents in an unindexed
33-
capped collection is close to the speed of logging to a
34-
filesystem. Additionally, with the built-in FIFO mechanism, you are
35-
not at risk of using excessive disk space for the logging.
24+
- Capped collections guarantee that insertion order is identical to the
25+
order on disk (:term:`natural order`) and do so by prohibiting updates
26+
that increase document size. Capped collections only allow updates
27+
that fit the original document size, which ensures a document does not
28+
change its location on disk.
3629

37-
- Automatic Maintaining of Insertion Order
30+
- Capped collections automatically remove the oldest documents in the
31+
collection without requiring scripts or explicit remove operations.
3832

39-
Capped collections keep documents in their insertion order
40-
automatically, with no index being required for this property. The
41-
logging example above is a good example of a case where keeping items
42-
in order is important.
33+
Capped collections provide a high-performance means for storing logging
34+
information. Inserting documents in an unindexed capped collection is
35+
close to the speed of logging to a filesystem. Additionally, the
36+
built-in FIFO mechanism ensures logging does not use excessive disk
37+
space.
4338

44-
- Caching
39+
Capped collections also provide a convenient way to cache known small
40+
numbers of documents, such as cached computations of information. This
41+
scenario would likely have more reads than writes and require an index.
4542

46-
If you wish to cache a small number of documents in the database,
47-
perhaps cached computations of information, the capped tables provide
48-
a convenient mechanism for this. Note that for this application you
49-
typically use an index on the capped table as there are be more reads
50-
than writes.
51-
52-
- Automatic Age Out
53-
54-
If you know you want data to automatically "roll out" over time as it
55-
ages, a capped collection can be an easier way to support than writing
56-
manual removal via cron scripts. Ejection from the capped collection
57-
is also inexpensive compared to explicit remove operations.
43+
The :term:`oplog.rs <oplog>` collection used in replication is an
44+
example of a capped collection.
5845

5946
Recommendations and Restrictions
6047
--------------------------------
6148

49+
You cannot shard a capped collection.
50+
6251
You may update the existing documents in the collection. However, the
6352
documents must not grow in size. If they do, the update fails.
6453

0 commit comments

Comments
 (0)