Index in MongoDB
noun
say it: “IN-deks in MONG-goh-DEE-BEE” /ˈɪndɛks ɪn ˈmɑŋɡoʊˌdiˌbi/
A structure MongoDB keeps on a field so queries on it find documents without reading every one.
What is Index in MongoDB?
An index makes queries on a field fast instead of scanning every document. _id is indexed automatically.
db.recipes.createIndex({ category: 1 })
In a sentence
- “After an index on farm.town, the search read 3 documents instead of 3,000.”
- “MongoDB makes an index on _id for every collection.”
Level: Journeyman · More MongoDB terms at this level
Updated