Compaction
Compaction rebuilds collection storage to remove fragmentation and then rebuilds indexes.
db.compactCollection(name)
compactCollection(name: string): Promise<void>
db.compactAll()
compactAll(): Promise<void>
collection.compact()
compact(): Promise<void>
The compaction engine performs:
- crash recovery checks
- snapshot rebuild to a temporary directory
- atomic directory swap
- reopen DB
- rebuild indexes