Docs Menu

Docs HomeMongoDB Atlas

Atlas Search Query Performance

On this page

  • Query Operators and Query Complexity
  • Performance Monitoring
  • $match Aggregation Stage Usage
  • $sort Aggregation Stage Usage

The complexity level of Atlas Search queries and the type of operators used can affect database performance. Highly complex queries with multiple clauses are resource-intensive, as are queries which use the regex (regular expression) operator.

Atlas Search queries are ranked by score. Queries that return a large number of results are more computationally intensive because they must keep track of all the scores for the result set.

You can monitor your Atlas cluster and view charts with performance statistics on the Atlas Metrics tab. These metrics can help you see how Atlas Search queries and index building affect your cluster's performance. To learn more, see Review Atlas Search Metrics.

Atlas might trigger some Atlas alerts when:

  • Atlas Search queries your database deployments, which can impact Atlas performance metrics, such as the query targeting metrics.

  • Atlas Search replicates data from MongoDB, which contributes to the metrics measured in Atlas, such as the number of getmore operations.

Note

If your cluster's resources are stretched or near the limits of acceptable performance, consider upgrading to a larger cluster tier before implementing Atlas Search functionality.

Using a $match aggregation pipeline stage after a $search stage can drastically slow down query results. If possible, design your $search query so that all necessary filtering occurs in the $search stage to remove the need for a $match stage. The $compound Atlas Search operator is helpful for queries that require multiple filtering operations. If you must use the $match stage in your aggregation pipeline, consider using the storedSource option to store only the fields that your $match condition needs. You can then use the returnStoredSource option to retrieve stored fields.

Tip

See also:

Using a $sort aggregation pipeline stage after a $search stage can drastically slow down query results. If possible, design your $search query so that all necessary sorting occurs in the $search stage to remove the need for a $sort stage. In general, the Atlas Search $compound operator is helpful for queries that require multiple sorting operations. To sort documents based on a numeric, date, or geo field, consider using the Atlas Search $near operator. Alternatively, you can use the storedSource option to store only the fields that you need for $sort on Atlas Search and use the returnStoredSource option to retrieve stored fields.

←  Atlas Search Index PerformanceFix Atlas Search Issues →
Share Feedback
© 2023 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2023 MongoDB, Inc.