Performance Considerations¶
Atlas Search runs a new process, called mongot
, alongside
the mongod
process on each host in your
Atlas cluster. mongot
maintains all
Atlas Search indexes on collections in your Atlas databases.
The amount of CPU, memory, and disk resources mongot
consumes
depends on several factors, including your index configuration
and the complexity of your queries.
Index Size and Configuration¶
When you create an Atlas Search index, the default configuration sets field mapping to dynamic, which means that all the data in your collection is actively added to your Atlas Search index. Other options such as enabling highlights can also result in your index taking up more disk space. You can reduce the size and performance footprint of your Atlas Search index by:
- Specifying a custom index definition to narrow the amount and type of data that is indexed.
- Setting the
store
option tofalse
when specifying a string type in an index definition.
Creating and Updating an Atlas Search Index¶
Creating an Atlas Search index is resource-intensive. The performance of your Atlas cluster may be impacted while the index builds.
If you change the configuration of an Atlas Search index it must rebuild, which also consumes resources and may affect database performance.
Do not run queries against an Atlas Search index while it is building. Ensure that all nodes in your cluster have the Active status before running Atlas Search queries.
Query Operators and Query Complexity¶
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.
Performance Monitoring¶
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.
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.
$match
Aggregation Stage Usage¶
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.
$sort
Aggregation Stage Usage¶
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.