---
title: "List Postgres slow query patterns"
method: GET
path: "/v1/organizations/{organizationId}/postgres/{postgresId}/slowQueryPatterns"
tags: ["Postgres"]
---

# List Postgres slow query patterns

`GET /v1/organizations/{organizationId}/postgres/{postgresId}/slowQueryPatterns`

## Request

- Base URL: `https://api.clickhouse.cloud`
- URL: `https://api.clickhouse.cloud/v1/organizations/{organizationId}/postgres/{postgresId}/slowQueryPatterns`
- Auth: HTTP basic

Returns aggregate metrics for the slowest query patterns observed on a Postgres service during the given time window. Use this to discover which queries dominate total execution time, CPU, I/O, or WAL generation.

## Path parameters

- `organizationId` string, uuid, required
- `postgresId` string, uuid, required

## Query parameters

- `from_date` string, date-time, required
- `to_date` string, date-time, required
- `db_name` string
- `db_user` string
- `db_operation` string
- `app` string
- `sort_by` 'total_duration' | 'avg_duration' | 'call_count' | 'total_blks_read' | 'total_cpu_time' | 'error_count' | 'max_duration' | 'p50_duration' | 'p95_duration' | 'p99_duration' | 'total_rows' | 'total_shared_blks_hit' | 'total_wal_bytes'
- `sort_order` 'asc' | 'desc'
- `limit` integer
- `offset` integer

## Response `200`

Successful response

- object
  - `status` number: HTTP status code.
  - `requestId` string, uuid: Unique id assigned to every request. UUIDv4
  - `result` PostgresSlowQueryPattern[]: List of results.
    - `queryId` string, required: Stable identifier for the query pattern (normalized SQL).
    - `queryText` string, required: Normalized query text with literals replaced by placeholders.
    - `dbName` string, required: Database the query ran in.
    - `dbUser` string, required: Database user that executed the query.
    - `dbOperation` string, required: Top-level SQL operation type (for example, SELECT, INSERT, UPDATE, DELETE, UTILITY).
    - `app` string, required: Value of the Postgres `application_name` for executions matching this pattern.
    - `callCount` integer, required: Number of times the pattern executed in the window.
    - `errorCount` integer, required: Number of executions of the pattern that raised an error.
    - `totalDurationUs` integer, required: Total execution time across all calls, in microseconds.
    - `avgDurationUs` number, required: Average execution time per call, in microseconds.
    - `maxDurationUs` integer, required: Maximum execution time of any call, in microseconds.
    - `p50DurationUs` number, required: 50th percentile execution time, in microseconds.
    - `p95DurationUs` number, required: 95th percentile execution time, in microseconds.
    - `p99DurationUs` number, required: 99th percentile execution time, in microseconds.
    - `totalRows` integer, required: Total number of rows returned or affected across all calls.
    - `totalSharedBlksRead` integer, required: Total shared buffer blocks read from disk (cache misses) across all calls.
    - `totalSharedBlksHit` integer, required: Total shared buffer blocks hit (cache hits) across all calls.
    - `totalCpuTimeUs` integer, required: Total CPU time across all calls, in microseconds.
    - `totalWalBytes` integer, required: Total WAL (write-ahead log) bytes generated across all calls.

## Other responses

- `400`: The request cannot be processed due to a client error. Please verify your request parameters and try again.
- `500`: An internal server error has occurred. If this issue persists, please contact ClickHouse Cloud support for assistance.

## Changes

- **2026-11-04** `63a9108321ca`: 4 breaking
  - the `result/items/avgDurationUs` response's property type changed from `integer` to `number` for status `200`
  - the `result/items/p50DurationUs` response's property type changed from `integer` to `number` for status `200`
  - the `result/items/p95DurationUs` response's property type changed from `integer` to `number` for status `200`
  - the `result/items/p99DurationUs` response's property type changed from `integer` to `number` for status `200`

[Operation history](https://skmtc.dev/clickhouse/apis/openapi-spec-for-clickhouse-cloud/changes/v1/organizations/:organizationId/postgres/:postgresId/slowQueryPatterns/get.md)

---

[API](https://skmtc.dev/clickhouse/apis/openapi-spec-for-clickhouse-cloud.md) - [All operations](https://skmtc.dev/clickhouse/apis/openapi-spec-for-clickhouse-cloud/llms.txt) - [OpenAPI document](https://skmtc.dev/clickhouse/apis/openapi-spec-for-clickhouse-cloud/revisions/eac345053548?raw)
