> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# Manage Atlas Indexes

Indexes are special data structures that improve query performance. Indexes store a portion of a collection's data in an easy-to-traverse form. The index stores the value of a specific field or set of fields, ordered by the value of the field.

To improve query performance, build indexes on fields that appear often in queries and for all operations that [sort by a field.](https://www.mongodb.com/docs/atlas/atlas-ui/query/sort.md#std-label-atlas-ui-query-bar-sort)

- Queries on an indexed field can use the index to limit the number of documents that must be scanned to find matching documents.

- Sort operations on an indexed field can return documents pre-sorted by the index.

To learn more about indexes, see [Indexes.](https://www.mongodb.com/docs/manual/indexes/)

**Note: Considerations**

Indexes have some negative performance impact on write operations. For collections with high write-to-read ratio, indexes are expensive since each insert must also update any indexes. For a detailed list of considerations for indexes, see [Operational Considerations for Indexes.](https://www.mongodb.com/docs/manual/data-modeling/best-practices.md#std-label-data-model-indexes)

## Required Roles

To create, drop, or hide indexes, you must have access provided by at least one of the following roles:

- [`Project Owner`](https://www.mongodb.com/docs/atlas/reference/user-roles.md#mongodb-authrole-Project-Owner) or [`Organization Owner`](https://www.mongodb.com/docs/atlas/reference/user-roles.md#mongodb-authrole-Organization-Owner)

- [`Project Data Access Admin`](https://www.mongodb.com/docs/atlas/reference/user-roles.md#mongodb-authrole-Project-Data-Access-Admin)

## Considerations

By default, you can have up to three concurrent index builds. To learn more, see [Maximum Concurrent Index Builds.](https://www.mongodb.com/docs/manual/core/index-creation/#maximum-concurrent-index-builds)

## View Indexes

**Warning:**

The Data Explorer only shows Usage metrics for the primary node in your cluster. If your application primarily reads from secondary nodes, the Usage metrics do not fully reflect index usage across your cluster.

For more comprehensive index usage statistics, run the [`$indexStats`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats.md#mongodb-pipeline-pipe.-indexStats) aggregation stage on each node in your cluster.

From the Indexes tab, you can view index information for a collection. To access the Indexes tab for a collection:

1. In Atlas, go to the Data Explorer page for your project.

   If it's not already displayed, select the organization that contains your project from the  Organizations menu in the navigation bar.

   If it's not already displayed, select your project from the Projects menu in the navigation bar.

   In the sidebar, click Data Explorer under the Database heading.

   The [Data Explorer](https://cloud.mongodb.com/go?l=https%3A%2F%2Fcloud.mongodb.com%2Fv2%2F%3Cproject%3E%23%2Fmetrics%2FreplicaSet%2F%3Creplset%3E%2Fexplorer) displays.

   IMPORTANT: You can also click the name of a cluster to open the Cluster sidebar, and then click Data Explorer under the Shortcuts heading.

2. View indexes.

   Select the collection.

   Click the Indexes tab.

For each index, Atlas displays the following information:

| Name and Definition | The name of the index and keys. |
| --- | --- |
| Type | Regular, text, geospatial or hashed index. |
| Size | How large the index is. |
| Usage | Number of times the primary node has used the index in a lookup since the index was created or the last server restart. This metric is for informational purposes only. To get comprehensive index usage statistics across all nodes, run the [`$indexStats`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats.md#mongodb-pipeline-pipe.-indexStats) aggregation stage on each node. |
| Properties | Any special properties (such as uniqueness, partial) of the index. |

## Create an Index

**Warning:**

Do not create indexes on encrypted fields. Creating indexes on encrypted fields that use [Queryable Encryption](https://www.mongodb.com/docs/manual/core/queryable-encryption/) negatively affect performance. Instead, you can create an index on the `__safeContent__` field to support queries on encrypted fields.

1. Open the index creation dialog

   From the [Indexes](https://www.mongodb.com/docs/atlas/atlas-ui/indexes.md#std-label-atlas-ui-indexes-tab) tab, click the Create
   Index button.

2. Add fields to the index

   Specify an index key.

   - To specify an existing document field as an index key, select the field from the dropdown list.

   - To specify a field that does not exist in any document as an index key, enter the field name in the input box.

   - To create a [compound index](https://www.mongodb.com/docs/manual/core/index-compound/), click the plus  icon next to the index type dropdown.

   Use the dropdown to the right of each field name to specify the index type. You can specify one of the following types:

   - Ascending

   - Descending

   - 2dsphere

   - Text

   To learn how to specify a wildcard index, see [Create a Wildcard Index.](https://www.mongodb.com/docs/atlas/atlas-ui/indexes.md#std-label-atlas-ui-wildcard-index)

3. Optional. Specify index options

   Atlas supports the following index options:

   | Option | Description | More Information |
   | --- | --- | --- |
   | Create unique index | Ensure that the indexed fields do not store duplicate values. You cannot perform a rolling build for a unique index. If you enable building indexes in a rolling fashion with the `unique` index option, Atlas rejects your configuration with an error message. | [Unique Indexes](https://www.mongodb.com/docs/manual/core/index-unique/) |
   | Index name | Specify a name for the index. | [Specify an Index Name](https://www.mongodb.com/docs/manual/core/indexes/create-index/specify-index-name.md#std-label-specify-index-name) |
   | Create a TTL (Time to Live) index | Delete documents automatically after a specified number of seconds since the indexed field value. | [TTL Indexes](https://www.mongodb.com/docs/manual/core/index-ttl/) |
   | Partial filter expression | Index only the documents which match the specified filter expression. For example: The following partial filter expression only indexes documents where the `timezone` field exists: `{ "timezone": { "$exists": true } }` | [Partial Indexes](https://www.mongodb.com/docs/manual/core/index-partial/) |
   | Wildcard projection | Support unknown or arbitrary fields which match the specified projection in the index. To use a wildcard projection, set your index field name to  `$**`. This directs Atlas to use all fields in the document (excluding `_id`). For example: Consider the following wildcard projection document: `{
     "product_attributes.elements" : 1,
     "product_attributes.resistance" : 1
   }` If your index field name is `$**`, your index only includes the values of the fields in that projection. | [Create a Wildcard Index](https://www.mongodb.com/docs/atlas/atlas-ui/indexes.md#std-label-atlas-ui-wildcard-index) |
   | Use custom collation | Create a custom collation for the index by typing or pasting the collation document in the text box. | [Collation Document](https://www.mongodb.com/docs/manual/reference/collation/#collation-document) |
   | Create sparse index | Index skips over any document that is missing the indexed field. | [Sparse Indexes](https://www.mongodb.com/docs/manual/core/index-sparse.md#std-label-index-type-sparse) |
   | Build in rolling process | Can minimize the performance impact of index builds. IMPORTANT: Building an index in a rolling fashion reduces the resiliency of your cluster and increases index build times. We only recommend using rolling index builds when regular index builds do not meet your needs. WARNING: Avoid performing rolling index and replicated index build processes concurrently as it might lead to unexpected issues, such as broken builds and crash loops. You can only build rolling indexes on M10+ Clusters. During a rolling index build, Atlas takes each node out of the replica set, starts it in standalone mode to build the index, and then returns it to the replica set. This process repeats for each node in the cluster in a rolling sequence. Nodes may appear as down, while Atlas builds indexes offline. This is expected behavior, not an issue. | [Rolling Index Builds](https://www.mongodb.com/docs/manual/core/rolling-index-builds.md#std-label-rolling-index-build) |

4. Click Create Index.

### MongoDB Vector Search and MongoDB Search Indexes

You can't create MongoDB Search or MongoDB Vector Search indexes in Data Explorer. To manage MongoDB Search and MongoDB Vector Search indexes for your collection, see:

- [Supported Clients.](https://www.mongodb.com/docs/search/indexes/manage-indexes.md#std-label-fts-manage-indexes)

- [Procedure](https://www.mongodb.com/docs/vector-search/indexes/vector-search-type.md#std-label-avs-create-index-procedure)

### Create a Wildcard Index

You can create [wildcard indexes](https://www.mongodb.com/docs/manual/core/index-wildcard/) to support queries against unknown or arbitrary fields. To create a wildcard index in Atlas, manually type the wildcard index field (`<field>.$**`) into the Select a field name input.

**Example:**

Consider a collection where documents contain a `userMetadata` object. The fields within the `userMetadata` object may vary between documents.

You can create a wildcard index on `userMetadata` to account for all potential fields within the object. Type the following into the Select a field name input:

```javascript
userMetadata.$**
```

Specify a type (`ascending` or `descending`) for your wildcard index, then click Create Index.

Atlas shows the type of your new index as Wildcard.

## Hide or Unhide an Index

You can [hide an index](https://www.mongodb.com/docs/manual/core/index-hidden/) from the query planner to evaluate the potential impact of dropping an index without actually dropping the index.

1. Hover over the index.

   From the Indexes tab, hover over the index you want to hide.

2. Click the Hide Index button.

   Click the closed-eye icon on the right that appears when you hover over your selected index.

3. Click Confirm.

   In the dialog box, confirm the index you want to hide. After you confirm your selection, a Hidden badge appears under the Properties column.

   To unhide your index, repeat steps 1-3. After you unhide your index, Atlas removes the Hidden badge from the Properties column.

## Drop an Index

1. Click the trash can icon for the index to drop.

   From the [Indexes](https://www.mongodb.com/docs/atlas/atlas-ui/indexes.md#std-label-atlas-ui-indexes-tab) tab, to delete an index, click on the trash can icon for that index. A confirmation dialog appears.

2. Confirm the index to delete.

   In the dialog, enter the name of the index to delete.

3. Click Drop to drop the index.
