mongodb/mongodb-create-index

Create Index

Create an index on a field

mongodb
index
performance

Command

db.users.createIndex({name:1})

Explanation

Creates an index on a collection field to improve query performance. Useful for large collections.

Examples

Create index on item field

db.orders.createIndex({item:1})