In this last chapter, we look at a few performance topics as well as some of the tools available to MongoDB developers.
We won’t dive deeply into either topic, but we will examine the most important aspects of each.
Indexes
At the very beginning we saw the
getIndexes
command which shows information on all the indexes in a collection.
Indexes in MongoDB work a lot like indexes in a relational database: they help improve query and sorting performance.
Indexes are created via
ensureIndex
:
// where "name" is the field name
db.unicorns.ensureIndex({name: 1});
And dropped via
dropIndex
:
db.unicorns.dropIndex({name: 1});
A unique index can be created by supplying a second parameter and setting
unique
to
Do'stlaringiz bilan baham: