> ## Documentation Index
> Fetch the complete documentation index at: https://codspeed.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Database Instrument Overview

> The database instruments measure the performance of database queries directly in the CI

The database instruments allow measuring the performance of **database queries**
directly in the CI. For each benchmark, information about the database queries
is displayed in the CodSpeed dashboard. The following performance issues can be
detected:

* **Un-optimized queries**: queries that are not using indexes or are not using
  them efficiently
* **N+1 queries**: queries that are executed multiple times for each item in a
  list instead of using a single query (*coming soon*)

![Example of a benchmark with an un-optimized MongoDB query](https://mintcdn.com/codspeed/_9gjNuBHMdsdxHot/instruments/databases/assets/unoptimized-query.png?fit=max\&auto=format\&n=_9gjNuBHMdsdxHot\&q=85\&s=53997d2e05e9a7def5eba52ff6dee1ad)

Example of a benchmark with an un-optimized MongoDB query

The following benefits can be expected from using the database instruments:

* Full visibility on the performance of your database queries, **directly in the
  CI**
* **Detect and fix problematic queries** before they are deployed to production

## How it works

When enabled, the CodSpeed Action will automatically spawn a proxy server that
will intercept all database queries. Each query will be executed against a real
database and the response sent back to the application.

![Databases Instruments architecture](https://mintcdn.com/codspeed/jKaxX6yy-Kzw1C-0/instruments/databases/assets/proxy.dark.png?fit=max\&auto=format\&n=jKaxX6yy-Kzw1C-0\&q=85\&s=a51f53169d944f725ad1a0dcb171a37f)

For each query, the CodSpeed proxy will communicate with the real database to
gather the **explain plan** and other metrics about it. When the run is
finished, the data is sent to CodSpeed where it is processed.

## Supported Databases

> [card] [MongoDB](https://codspeed.io/docs/instruments/databases/mongodb.md)

> [!NOTE]
>
> If there is another database you would like to see supported, please reach out
> to us via [Discord](https://discord.gg/MxpaCfKSqF) or
> [email out support](mailto:contact@codspeed.io).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.