- MongoDB indexes are the same as in any other relational database.
- Indexes are defined on collection level ( tables in RDBMS)
- MongoDB indexes user B-tree data structure.
- _id Identifier, Default, Cannot Drop Index, Unique
Types of Indexes
Single Field Index
indexes on single fields
Accending/Decending Order Index
Will make easier to search along the range and order
Embedded Document Index
index in location.state
or location as whole
TTL
- Automatically removes data after a specified amount of time
- Can be applied on the date field
- If a particular document does not have an indexed field or date field it will not expire
Compound Index
- The single index can hold information about multiple fields
- MongoDB holds 32 fields as maximum in a compound index
- Order of index definition is important if {a: 1, b: 1} is defined then index will first sort the collection with a and then within that for b
Multikey Index
Text Index
- A collection can have at most one
text index.
Wild Card Index
2dshpere Index
2d Index
GeoHayStack Index
Hashed Index
Index Properties
No comments:
Post a Comment