Indexing & Aggregation
Unindexed database queries degrade performance as tables grow. By utilizing single-field, compound, and multikey indices, and leveraging the aggregation pipeline, developers construct highly efficient query paths.
Curated Video Reference
YouTubeHand-picked video lecture to deepen your understanding of Indexing & Aggregation

SQL in 100 Seconds
Fireship•Click to watch here
Knowledge Check
2 questions · pass at 70%
1. If you have a compound index on `{ companyId: 1, age: 1 }`, which of the following queries will NOT be able to utilize this index?
Interview Questions
1 questionsCheatsheet
Download-ready referenceCOLLSCAN Collection Scan (slow O(N) read).
IXSCAN Index Scan (fast O(log N) read).
Covered A query where index keys contain all fields, reading 0 documents.
Index creation:
db.col.createIndex({ fieldName: 1 }) // Ascending
db.col.createIndex({ f1: 1, f2: -1 }) // Compound
Aggregation stages:
$match Filter documents.
$group Group and compute metrics ($sum, $avg).
$project Reshape/select fields.
$sort Order outputs.