44장. Aggregation을 Memory와 Spill까지 본다
pipeline은 filter와 projection을 가능한 앞에서 적용하되 stage 재배치를 무조건 추측하지 않고 explain으로 본다. $lookup, $group, $sort, $unwind의 cardinality 증가와 disk spill을 측정한다. unbounded array unwind와 전체 collection lookup을 API request 안에서 실행하지 않는다.
평균 주문·큰 주문·hot customer fixture로 p95와 scanned/returned, memory, temporary disk를 비교한다. materialized summary 또는 background aggregation을 쓰면 freshness, rebuild, correction과 source-of-truth를 계약한다. timeout 뒤 server operation이 계속되는지도 maxTimeMS와 client cancellation으로 확인한다.