1 · MongoDB · Anti-Pattern
run
An array that grows without limit
You shouldn't do that
Resize an array in place
{ _id: 1042, nickname: "Klinok",
feed: [
{ at: ..., text: "матч завершён" },
{ at: ..., text: "матч завершён" },
... ещё 300 тысяч элементов
] }
$push: { recent_feed: {
$each: [ новое_событие ],
$sort: { at: -1 },
$slice: 5
}}
// после операции — не больше пяти
// validator maxItems: 5 отклонит 6-й (121)
PROBLEM 1
PROBLEM 2
CHECK
Processing costs are rising
16 MB limit
A one-sentence check
More data, indexing, and competition for each document. Projection reduces response time, but doesn't promise low-cost I/O.
Hard limit; 100 levels of nesting.
Name the number N and explain what determines it for all recording paths. “Delete at the end of the season” is not an answer.
History is a separate issue. The full feed is a collection with `player_id` and an index of `{ player_id: 1, at: -1 }`. `$slice` discards elements but does not archive them. Measure `$bsonSize` and run `explain`.