Index Basics
Index Basics: Why Queries Get Slow, and What an Index Is, Reading explain(): COLLSCAN or IXSCAN.
Updated
- Why Queries Get Slow, and What an Index Is (Apprentice): A query with no index reads every document in the collection, which is fine for 50 orders and slow for 100,000, while an index keeps one field's values in order so MongoDB can go straight to the matches, at a cost in disk space and in every write.
- Reading explain(): COLLSCAN or IXSCAN (Journeyman): explain with "executionStats" is MongoDB's report on how it ran a query, where the winning plan's stages say whether it read every document (COLLSCAN) or used an index (IXSCAN, then FETCH), and totalDocsExamined against nReturned says how much work each result cost.