---
title: "sql_query | Speedscale Docs"
description: "Extract the SQL statement of a Postgres, MySQL or SQL Server request with the sql_query extractor."
canonical: "https://docs.speedscale.com/guides/transformation/extractors/sql_query/"
---

[Documentation index](https://docs.speedscale.com/guides/llms.txt) | [Markdown](https://docs.speedscale.com/guides/transformation/extractors/sql_query/index.md) | [Canonical page](https://docs.speedscale.com/guides/transformation/extractors/sql_query/)

# sql\_query

<a id="purpose"></a>

### Purpose

**sql\_query** extracts the SQL statement of a Postgres, MySQL or SQL Server request: a simple query or batch, or the statement behind a prepare, describe, bind, execute or RPC, such as the statement of an `sp_executesql`.

<a id="usage"></a>

### Usage

```json
"extractor": {
  "type": "sql_query"
}
```

It takes no configuration. It applies to requests only.

Pair it with the SQL signature transforms, such as [`sql_fingerprint`](https://docs.speedscale.com/guides/transformation/transforms/sql_fingerprint/) or [`sql_key_params`](https://docs.speedscale.com/guides/transformation/transforms/sql_key_params/), to tune how mocks match. Those transforms leave the statement unchanged. Any other transform that changes the extracted text rewrites the statement itself.

<a id="example"></a>

### Example

A request for `SELECT name FROM users WHERE id = $1`, sent as a prepared statement, extracts the text `SELECT name FROM users WHERE id = $1` from every message of that statement.

<a id="related"></a>

## Related

*   [Matching SQL mocks](https://docs.speedscale.com/guides/databases/mock-a-database/) explains how SQL mocks match and how the SQL transforms change that.
