Collection Scan
noun
say it: “kuh-LEK-shun SKAN” /kəˈlɛkʃən ˈskæn/
Reading every record in a collection to find the ones a query asks for, which happens when no index can help.
What is a collection scan?
A collection scan is MongoDB reading every document in a collection to check it against a query's filter, because no index fits the query. It's fine for a hundred documents and slow for a million; explain() shows it as COLLSCAN.
db.orders.find({ customerId: 31 }).explain("executionStats");
// winningPlan: { stage: 'COLLSCAN', ... }
// executionStats: { nReturned: 12, totalDocsExamined: 50000, ... }
In a sentence
- “explain() showed a collection scan: 50,000 orders examined to return 12.”
- “After createIndex, the collection scan became an index scan.”
Level: Journeyman · More MongoDB terms at this level
Updated