|
1 |
| -Inserting the same field/value pair into multiple documents in close |
2 |
| -succession can cause conflicts that delay insert operations. |
| 1 | +Concurrent write operations, such as inserting the same field/value pair into |
| 2 | +multiple documents in close succession, can cause contention: conflicts that |
| 3 | +delay operations. |
3 | 4 |
|
4 |
| -MongoDB tracks the occurrences of each field/value pair in an |
| 5 | +With {+qe+}, MongoDB tracks the occurrences of each field/value pair in an |
5 | 6 | encrypted collection using an internal counter. The contention factor
|
6 | 7 | partitions this counter, similar to an array. This minimizes issues with
|
7 | 8 | incrementing the counter when using ``insert``, ``update``, or ``findAndModify`` to add or modify an encrypted field
|
8 | 9 | with the same field/value pair in close succession. ``contention = 0``
|
9 |
| -creates an array with one element |
10 |
| -at index 0. ``contention = 4`` creates an array with 5 elements at |
11 |
| -indexes 0-4. MongoDB increments a random array element during insert. If |
12 |
| -unset, ``contention`` defaults to 8. |
| 10 | +creates an array with one element at index 0. ``contention = 4`` creates an |
| 11 | +array with 5 elements at indexes 0-4. MongoDB increments a random array element |
| 12 | +during insert. |
13 | 13 |
|
14 |
| -High contention improves the performance of insert and update operations |
15 |
| -on low cardinality fields, but decreases find performance. |
16 |
| - |
17 |
| -Consider increasing ``contention`` above the default value of 8 only if: |
18 |
| - |
19 |
| -- The field has low cardinality or low selectivity. A ``state`` field |
20 |
| - may have 50 values, but if 99% of the data points use ``{state: NY}``, |
21 |
| - that pair is likely to cause contention. |
22 |
| - |
23 |
| -- Write and update operations frequently modify the field. Since high |
24 |
| - contention values sacrifice find performance in favor of write and |
25 |
| - update operations, the benefit of a high contention factor for a |
26 |
| - rarely updated field is unlikely to outweigh the drawback. |
27 |
| - |
28 |
| -Some other examples of low cardinality fields are credit card types, |
29 |
| -gender, and ethnicity. |
30 |
| - |
31 |
| -Consider decreasing ``contention`` if: |
32 |
| - |
33 |
| -- The field is high cardinality and contains entirely unique values, |
34 |
| - such as a credit card number. |
35 |
| - |
36 |
| -- The field is often queried, but never or rarely updated. In this |
37 |
| - case, find performance is preferable to write and update performance. |
38 |
| - |
39 |
| -Some other examples of high cardinality fields are mobile phone numbers, |
40 |
| -social security numbers, full names, and addresses. |
| 14 | +When unset, ``contention`` defaults to ``8``, which provides high performance |
| 15 | +for most workloads. Higher contention improves the performance of insert and |
| 16 | +update operations on low cardinality fields, but decreases find performance. |
0 commit comments