---
title: "SQL statements, values and compare | Speedscale Docs"
description: "List every SQL statement in a Speedscale snapshot with its latency, rows and parameter values, filter traffic to one statement shape, and compare the SQL of two snapshots or reports to catch dropped WHERE clauses, N+1 queries and migrations."
canonical: "https://docs.speedscale.com/guides/databases/sql-statements/"
---

[Documentation index](https://docs.speedscale.com/guides/llms.txt) | [Markdown](https://docs.speedscale.com/guides/databases/sql-statements/index.md) | [Canonical page](https://docs.speedscale.com/guides/databases/sql-statements/)

# SQL statements, values and compare

The **Database** view of a snapshot lists the SQL statements your services ran, with how often, how fast and how many rows each touched, and which values were passed to it. It can also compare the SQL of two snapshots or replay reports. It runs the same analysis as proxymock web, so the same recording gives the same statements in both.

Open a snapshot's **Traffic** tab, then choose **Database**.

<a id="list-the-statements"></a>

## List the statements

Choose **Statements** at the top of the view. The summary counts unique statements, recorded queries, tables, services, hosts and protocols. **Rank statements by** orders the list:

*   **Busiest**: by how many times each statement ran.
*   **Slowest**: by p95 latency across every recorded execution.
*   **Most rows**: by the average rows a call returned or changed.

Click a statement for its full stats: protocol, tables, services and hosts, minimum, average, p95 and maximum latency, rows, and how often each route ran it. In the **Tables** view, each statement that matches the inventory shows its p95, average and rows on one line.

<a id="see-the-values-passed-to-a-statement"></a>

## See the values passed to a statement

**Values** shows, for each parameter or literal position, how many distinct values it took and, for each value, how many calls used it, the total and p95 time, its share of the calls and its errors. A value that dominates one position, or one slow value, often explains a slow statement. Values are kept for the 200 busiest statements.

<a id="filter-to-one-statement-shape"></a>

## Filter to one statement shape

**Filter to this shape** opens the outbound **Requests** list filtered to every call of that statement, with any values, so you can open the calls themselves. See [Find statements with filters](https://docs.speedscale.com/guides/databases/find-statements/) for the other database filters.

<a id="compare-the-sql-of-two-recordings"></a>

## Compare the SQL of two recordings

**Compare SQL with...** is on the **Database** view of a snapshot and on the **Performance** tab of a report. From a snapshot, compare with **A replay of this snapshot** or **Another snapshot**. From a report, compare with **This report's recording**, **Another report of the snapshot** or **Another snapshot**. The recording is the baseline by default, and **Swap sides** changes it. Every change is the candidate minus the baseline.

**What changed** lists the findings first, for example an `UPDATE` or `DELETE` that lost its `WHERE` clause and now affects every row, a new query that runs once per row (a possible N+1), or a schema migration that ran on one side only. Below it:

*   **Statements**: the statements that are new, changed, removed or present on both sides. A changed statement shows what was added and removed, and **WHERE dropped** marks one that lost its filter.
*   **Performance**: p95 regressions, count changes per 1,000 queries, database time by table, and statements per request by endpoint. Latency changes count only when each side has at least five timed calls.
*   **Tables and schema**: migrations with the side they ran on, the operations each table saw on each side, and columns that appeared or disappeared.

<a id="keep-in-mind"></a>

## Keep in mind

A snapshot or report analyzed before the SQL inventory existed shows a note; reanalyze the snapshot or replay again. Each inventory reads up to the first 1,000,000 statements and inbound requests and says so when it stops early.
