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

# ClickHouse Cloud: Clickhouse Slow Query Patterns Get List

> List the slowest query patterns on a ClickHouse Cloud Postgres service over a time window. Includes inputs, outputs, SDK V2 examples, and Deepline cost.

List the slowest query patterns on a ClickHouse Cloud Postgres service over a time window.

> [!NOTE]
>
> Tool ID: `clickhouse_slow_query_patterns_get_list`

## Run this action

Use the TypeScript SDK for one call. Use `ctx.tools.execute(...)` inside a Play for durable calls, scheduled calls, or CSV processing.

```ts theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
import { Deepline } from 'deepline';

const deepline = await Deepline.connect();
const result = await deepline.tools.execute(
  'clickhouse_slow_query_patterns_get_list',
  {
    "organizationId": "123e4567-e89b-42d3-a456-426614174000",
    "postgresId": "123e4567-e89b-42d3-a456-426614174000",
    "from_date": "2026-01-15T12:00:00Z",
    "to_date": "2026-01-15T12:00:00Z"
  },
);

console.log(result.toolResponse.raw);
```

### CLI

```bash theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
deepline tools execute clickhouse_slow_query_patterns_get_list --input '{
  "organizationId": "123e4567-e89b-42d3-a456-426614174000",
  "postgresId": "123e4567-e89b-42d3-a456-426614174000",
  "from_date": "2026-01-15T12:00:00Z",
  "to_date": "2026-01-15T12:00:00Z"
}' --json
```

## Example response

The SDK returns this shape at `result.toolResponse.raw`. The example values illustrate the response.

```json theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
{
  "data": {
    "status": 123,
    "requestId": "123e4567-e89b-42d3-a456-426614174000",
    "result": [
      {
        "queryId": "query_123",
        "queryText": "software companies hiring engineers",
        "dbName": "Example",
        "dbUser": "example",
        "dbOperation": "example",
        "app": "example",
        "callCount": 123,
        "errorCount": 123,
        "totalDurationUs": 123,
        "avgDurationUs": 123,
        "maxDurationUs": 123,
        "p50DurationUs": 123,
        "p95DurationUs": 123,
        "p99DurationUs": 123,
        "totalRows": 123,
        "totalSharedBlksRead": 123,
        "totalSharedBlksHit": 123,
        "totalCpuTimeUs": 123,
        "totalWalBytes": 123
      }
    ]
  }
}
```

Use `deepline describe clickhouse_slow_query_patterns_get_list --json` for the latest machine-readable contract.

## Input reference

**This endpoint is in beta.** API contract is stable, and no breaking changes are expected in the future. 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.

| Name | Type | Required | Default | Details |
| - | - | - | - | - |
| `payload.organizationId` | `string` | Yes | — | ID of the organization that owns the Postgres service. Format: `uuid`. |
| `payload.postgresId` | `string` | Yes | — | ID of the requested Postgres service. Format: `uuid`. |
| `payload.from_date` | `string` | Yes | — | Inclusive start of the time window (RFC 3339 date-time). Format: `date-time`. |
| `payload.to_date` | `string` | Yes | — | Exclusive end of the time window (RFC 3339 date-time). Format: `date-time`. |
| `payload.db_name` | `string` | No | — | Database name filter. |
| `payload.db_user` | `string` | No | — | Database user filter. |
| `payload.db_operation` | `string` | No | — | Database operation filter (for example, SELECT, INSERT, UPDATE, DELETE, UTILITY). |
| `payload.app` | `string` | No | — | Application name filter. |
| `payload.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"` | No | `"total_duration"` | Field to sort results by. Allowed: `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`. |
| `payload.sort_order` | `"asc" \| "desc"` | No | `"desc"` | Sort order. One of `asc` or `desc`. Allowed: `asc`, `desc`. |
| `payload.limit` | `integer` | No | `20` | Maximum number of results to return. Minimum: 1. Maximum: 500. |
| `payload.offset` | `integer` | No | `0` | Number of results to skip before returning. Minimum: 0. |

<details>
  <summary>Show raw input schema</summary>

  ### Input JSON Schema

  ```json theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
  {
    "type": "object",
    "description": "**This endpoint is in beta.** API contract is stable, and no breaking changes are expected in the future. 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.",
    "properties": {
      "organizationId": {
        "type": "string",
        "description": "ID of the organization that owns the Postgres service.",
        "format": "uuid"
      },
      "postgresId": {
        "type": "string",
        "description": "ID of the requested Postgres service.",
        "format": "uuid"
      },
      "from_date": {
        "type": "string",
        "description": "Inclusive start of the time window (RFC 3339 date-time).",
        "format": "date-time"
      },
      "to_date": {
        "type": "string",
        "description": "Exclusive end of the time window (RFC 3339 date-time).",
        "format": "date-time"
      },
      "db_name": {
        "type": "string",
        "description": "Database name filter."
      },
      "db_user": {
        "type": "string",
        "description": "Database user filter."
      },
      "db_operation": {
        "type": "string",
        "description": "Database operation filter (for example, SELECT, INSERT, UPDATE, DELETE, UTILITY)."
      },
      "app": {
        "type": "string",
        "description": "Application name filter."
      },
      "sort_by": {
        "type": "string",
        "description": "Field to sort results by.",
        "default": "total_duration",
        "enum": [
          "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": {
        "type": "string",
        "description": "Sort order. One of `asc` or `desc`.",
        "default": "desc",
        "enum": [
          "asc",
          "desc"
        ]
      },
      "limit": {
        "type": "integer",
        "description": "Maximum number of results to return.",
        "default": 20,
        "minimum": 1,
        "maximum": 500
      },
      "offset": {
        "type": "integer",
        "description": "Number of results to skip before returning.",
        "default": 0,
        "minimum": 0
      }
    },
    "required": [
      "organizationId",
      "postgresId",
      "from_date",
      "to_date"
    ],
    "additionalProperties": false
  }
  ```
</details>

## Output reference

Standard tool result payload.

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

<details>
  <summary>Show raw output schema</summary>

  ### Output JSON Schema

  ```json theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
  {
    "type": "object",
    "description": "Standard tool result payload.",
    "properties": {
      "data": {
        "type": "object",
        "description": "Provider response payload.",
        "properties": {
          "status": {
            "type": "number",
            "description": "HTTP status code."
          },
          "requestId": {
            "type": "string",
            "description": "Unique id assigned to every request. UUIDv4",
            "format": "uuid"
          },
          "result": {
            "type": "array",
            "items": {
              "properties": {
                "queryId": {
                  "type": "string",
                  "description": "Stable identifier for the query pattern (normalized SQL)."
                },
                "queryText": {
                  "type": "string",
                  "description": "Normalized query text with literals replaced by placeholders."
                },
                "dbName": {
                  "type": "string",
                  "description": "Database the query ran in."
                },
                "dbUser": {
                  "type": "string",
                  "description": "Database user that executed the query."
                },
                "dbOperation": {
                  "type": "string",
                  "description": "Top-level SQL operation type (for example, SELECT, INSERT, UPDATE, DELETE, UTILITY)."
                },
                "app": {
                  "type": "string",
                  "description": "Value of the Postgres `application_name` for executions matching this pattern."
                },
                "callCount": {
                  "type": "integer",
                  "description": "Number of times the pattern executed in the window."
                },
                "errorCount": {
                  "type": "integer",
                  "description": "Number of executions of the pattern that raised an error."
                },
                "totalDurationUs": {
                  "type": "integer",
                  "description": "Total execution time across all calls, in microseconds."
                },
                "avgDurationUs": {
                  "type": "integer",
                  "description": "Average execution time per call, in microseconds."
                },
                "maxDurationUs": {
                  "type": "integer",
                  "description": "Maximum execution time of any call, in microseconds."
                },
                "p50DurationUs": {
                  "type": "integer",
                  "description": "50th percentile execution time, in microseconds."
                },
                "p95DurationUs": {
                  "type": "integer",
                  "description": "95th percentile execution time, in microseconds."
                },
                "p99DurationUs": {
                  "type": "integer",
                  "description": "99th percentile execution time, in microseconds."
                },
                "totalRows": {
                  "type": "integer",
                  "description": "Total number of rows returned or affected across all calls."
                },
                "totalSharedBlksRead": {
                  "type": "integer",
                  "description": "Total shared buffer blocks read from disk (cache misses) across all calls."
                },
                "totalSharedBlksHit": {
                  "type": "integer",
                  "description": "Total shared buffer blocks hit (cache hits) across all calls."
                },
                "totalCpuTimeUs": {
                  "type": "integer",
                  "description": "Total CPU time across all calls, in microseconds."
                },
                "totalWalBytes": {
                  "type": "integer",
                  "description": "Total WAL (write-ahead log) bytes generated across all calls."
                }
              },
              "required": [
                "queryId",
                "queryText",
                "dbName",
                "dbUser",
                "dbOperation",
                "app",
                "callCount",
                "errorCount",
                "totalDurationUs",
                "avgDurationUs",
                "maxDurationUs",
                "p50DurationUs",
                "p95DurationUs",
                "p99DurationUs",
                "totalRows",
                "totalSharedBlksRead",
                "totalSharedBlksHit",
                "totalCpuTimeUs",
                "totalWalBytes"
              ],
              "additionalProperties": false
            }
          }
        },
        "additionalProperties": false
      },
      "meta": {
        "type": "object",
        "description": "Additional response metadata (status, paging).",
        "additionalProperties": true
      }
    },
    "required": [
      "data"
    ],
    "additionalProperties": false
  }
  ```
</details>

## Deepline cost

* Pricing model: `fixed` (per call).
* Estimated Deepline credits: `0` per pricing unit.
* Provider-native pricing may still exist outside Deepline credit billing.

## Related documentation

* [ClickHouse Cloud provider guide](https://deepline.com/docs/providers/clickhouse/guide.md)
* [SDK V2 quickstart](https://deepline.com/docs/sdk-v2/quickstart.md)
* [SDK reference](https://deepline.com/docs/sdk-v2/sdk-reference.md)
* [Run tools across a CSV](https://deepline.com/docs/sdk-v2/batch-csv.md)


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