Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The database might use the index to filter the collection, and afterwards sort the collection. It is customary build an index with the best filteroption first (using filtering out the most results for your use), and end with the sorting attribute where possible.

Without any index, MongoDB needs to browse through all documents when performing a query. When the database grows, it might lead to higher CPU load on the system. Make sure to regularly check the database to use indices at the queries performed often. MongoDB can be configured to log its slow queries. When testing your application, you might want to log and analyse any slow queries, to optimise the indices and performance of the database. Example configuration:

Code Block
titlemongod.conf
# Enable query logging (verbose mode)
operationProfiling:
  mode: slowOp
  slowOpThresholdMs: 100


Example

In the DCM Foundation there is a list for cases where the user is involved. To tune this list, we could have a look at the specific container:

...