---
title: "Get slow queries"
method: GET
path: "/api/v1/databases/{database_id}/slow-queries"
tags: ["Managed Databases"]
---

# Get slow queries

`GET /api/v1/databases/{database_id}/slow-queries`

The slowest recent queries.

- **PostgreSQL** — aggregated statistics from `pg_stat_statements`: each row is one normalized query with its call count, mean, and total time.
- **Valkey** — individual slow commands from `SLOWLOG`: `calls` is 1 per entry and `rows` is not applicable.

`collecting` indicates whether statistics collection is active yet.

## Path parameters

- `database_id` string, required

## Query parameters

- `limit` integer

## Response `200`

Slow query entries

- object
  - `success` boolean
  - `queries` DatabaseSlowQuery[]
    - `query` string — Normalized query text (PostgreSQL) or the slow command (Valkey)
    - `calls` integer — Number of executions aggregated into this entry
    - `mean_ms` number — Mean execution time in milliseconds
    - `total_ms` number — Total execution time in milliseconds
    - `rows` integer — Total rows returned or affected (PostgreSQL)
  - `collecting` boolean — Whether slow-query statistics are being collected

## Other responses

- `401` — Authentication required
- `404` — Resource not found

---

[API](https://skmtc.dev/rafftechnologies/apis/raff-api.md) · [All operations](https://skmtc.dev/rafftechnologies/apis/raff-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/rafftechnologies/raff-api/revisions/2f4df56be77c/schema)
