> ## 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 Pattern Get

> Get a Postgres slow query pattern with recent executions. Includes SDK V2 guidance, input constraints, response fields, and Deepline credit cost.

Get a Postgres slow query pattern with recent executions.

<Info>
  Tool ID: `clickhouse_slow_query_pattern_get`
</Info>

## Run this action

Use the TypeScript SDK for a single call. Put `ctx.tools.execute(...)` inside a Play when the call should be durable, scheduled, or run across a CSV.

```ts theme={null}
import { Deepline } from 'deepline';

const deepline = await Deepline.connect();
const result = await deepline.tools.execute(
  'clickhouse_slow_query_pattern_get',
  {
    "organizationId": "123e4567-e89b-42d3-a456-426614174000",
    "postgresId": "123e4567-e89b-42d3-a456-426614174000",
    "queryId": "query_123",
    "db_name": "Example",
    "db_user": "example",
    "db_operation": "example"
  },
);

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

### CLI

```bash theme={null}
deepline tools execute clickhouse_slow_query_pattern_get --input '{
  "organizationId": "123e4567-e89b-42d3-a456-426614174000",
  "postgresId": "123e4567-e89b-42d3-a456-426614174000",
  "queryId": "query_123",
  "db_name": "Example",
  "db_user": "example",
  "db_operation": "example"
}' --json
```

## Example response

The SDK exposes this shape at `result.toolResponse.raw`. Values below are representative.

```json theme={null}
{
  "data": {
    "status": 123,
    "requestId": "123e4567-e89b-42d3-a456-426614174000",
    "result": {
      "recentExecutions": [
        {
          "timestamp": "2026-01-15T12:00:00Z",
          "queryId": "query_123",
          "dbName": "Example",
          "dbUser": "example",
          "dbOperation": "example",
          "app": "example",
          "queryText": "software companies hiring engineers",
          "pid": "example",
          "durationUs": 123,
          "rows": 123,
          "sharedBlksHit": 123,
          "sharedBlksRead": 123,
          "sharedBlksWritten": 123,
          "sharedBlksDirtied": 123,
          "sharedBlkReadTimeUs": 123,
          "sharedBlkWriteTimeUs": 123,
          "localBlksHit": 123,
          "localBlksRead": 123,
          "localBlksWritten": 123,
          "localBlksDirtied": 123,
          "tempBlksRead": 123,
          "tempBlksWritten": 123,
          "tempBlkReadTimeUs": 123,
          "tempBlkWriteTimeUs": 123,
          "walRecords": 123,
          "walBytes": 123,
          "walFpi": 123,
          "cpuUserTimeUs": 123,
          "cpuSysTimeUs": 123,
          "jitFunctions": 123,
          "jitGenerationTimeUs": 123,
          "jitInliningTimeUs": 123,
          "jitOptimizationTimeUs": 123,
          "jitEmissionTimeUs": 123,
          "jitDeformTimeUs": 123,
          "parallelWorkersPlanned": 123,
          "parallelWorkersLaunched": 123,
          "serverRole": "example"
        }
      ]
    }
  }
}
```

Use `deepline tools get clickhouse_slow_query_pattern_get --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 a single slow query pattern together with its most recent individual executions.

| 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.queryId` | `string` | Yes | — | Stable identifier for the query pattern. |
| `payload.db_name` | `string` | Yes | — | Database name filter. |
| `payload.db_user` | `string` | Yes | — | Database user filter. |
| `payload.db_operation` | `string` | Yes | — | Database operation filter (for example, SELECT, INSERT, UPDATE, DELETE, UTILITY). |
| `payload.app` | `string` | No | — | Application name filter. |
| `payload.timestamp` | `string` | No | — | Timestamp of a specific execution (RFC 3339). Format: `date-time`. |

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

  ### Input JSON Schema

  ```json theme={null}
  {
    "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 a single slow query pattern together with its most recent individual executions.",
    "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"
      },
      "queryId": {
        "type": "string",
        "description": "Stable identifier for the query pattern."
      },
      "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."
      },
      "timestamp": {
        "type": "string",
        "description": "Timestamp of a specific execution (RFC 3339).",
        "format": "date-time"
      }
    },
    "required": [
      "organizationId",
      "postgresId",
      "queryId",
      "db_name",
      "db_user",
      "db_operation"
    ],
    "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` | `object` | No | — | — |
| `result.data.result.aggregate` | `object` | No | — | — |
| `result.data.result.aggregate.queryId` | `string` | Yes | — | Stable identifier for the query pattern (normalized SQL). |
| `result.data.result.aggregate.queryText` | `string` | Yes | — | Normalized query text with literals replaced by placeholders. |
| `result.data.result.aggregate.dbName` | `string` | Yes | — | Database the query ran in. |
| `result.data.result.aggregate.dbUser` | `string` | Yes | — | Database user that executed the query. |
| `result.data.result.aggregate.dbOperation` | `string` | Yes | — | Top-level SQL operation type (for example, SELECT, INSERT, UPDATE, DELETE, UTILITY). |
| `result.data.result.aggregate.app` | `string` | Yes | — | Value of the Postgres `application_name` for executions matching this pattern. |
| `result.data.result.aggregate.callCount` | `integer` | Yes | — | Number of times the pattern executed in the window. |
| `result.data.result.aggregate.errorCount` | `integer` | Yes | — | Number of executions of the pattern that raised an error. |
| `result.data.result.aggregate.totalDurationUs` | `integer` | Yes | — | Total execution time across all calls, in microseconds. |
| `result.data.result.aggregate.avgDurationUs` | `integer` | Yes | — | Average execution time per call, in microseconds. |
| `result.data.result.aggregate.maxDurationUs` | `integer` | Yes | — | Maximum execution time of any call, in microseconds. |
| `result.data.result.aggregate.p50DurationUs` | `integer` | Yes | — | 50th percentile execution time, in microseconds. |
| `result.data.result.aggregate.p95DurationUs` | `integer` | Yes | — | 95th percentile execution time, in microseconds. |
| `result.data.result.aggregate.p99DurationUs` | `integer` | Yes | — | 99th percentile execution time, in microseconds. |
| `result.data.result.aggregate.totalRows` | `integer` | Yes | — | Total number of rows returned or affected across all calls. |
| `result.data.result.aggregate.totalSharedBlksRead` | `integer` | Yes | — | Total shared buffer blocks read from disk (cache misses) across all calls. |
| `result.data.result.aggregate.totalSharedBlksHit` | `integer` | Yes | — | Total shared buffer blocks hit (cache hits) across all calls. |
| `result.data.result.aggregate.totalCpuTimeUs` | `integer` | Yes | — | Total CPU time across all calls, in microseconds. |
| `result.data.result.aggregate.totalWalBytes` | `integer` | Yes | — | Total WAL (write-ahead log) bytes generated across all calls. |
| `result.data.result.recentExecutions` | `array` | Yes | — | Recent individual executions matching the pattern. |
| `result.data.result.recentExecutions[].timestamp` | `string` | Yes | — | Execution timestamp (RFC 3339). Format: `date-time`. |
| `result.data.result.recentExecutions[].queryId` | `string` | Yes | — | Stable identifier for the query pattern. |
| `result.data.result.recentExecutions[].dbName` | `string` | Yes | — | Database the query ran in. |
| `result.data.result.recentExecutions[].dbUser` | `string` | Yes | — | Database user that executed the query. |
| `result.data.result.recentExecutions[].dbOperation` | `string` | Yes | — | Top-level SQL operation type. |
| `result.data.result.recentExecutions[].app` | `string` | Yes | — | Value of the Postgres `application_name` for this execution. |
| `result.data.result.recentExecutions[].queryText` | `string` | Yes | — | Normalized query text for this execution. |
| `result.data.result.recentExecutions[].pid` | `string` | Yes | — | Postgres backend process ID that executed the query. |
| `result.data.result.recentExecutions[].durationUs` | `integer` | Yes | — | Execution duration in microseconds. |
| `result.data.result.recentExecutions[].rows` | `integer` | Yes | — | Rows returned or affected. |
| `result.data.result.recentExecutions[].sharedBlksHit` | `integer` | Yes | — | Shared buffer blocks hit. |
| `result.data.result.recentExecutions[].sharedBlksRead` | `integer` | Yes | — | Shared buffer blocks read from disk. |
| `result.data.result.recentExecutions[].sharedBlksWritten` | `integer` | Yes | — | Shared buffer blocks written. |
| `result.data.result.recentExecutions[].sharedBlksDirtied` | `integer` | Yes | — | Shared buffer blocks dirtied. |
| `result.data.result.recentExecutions[].sharedBlkReadTimeUs` | `integer` | Yes | — | Time spent reading shared blocks, in microseconds. |
| `result.data.result.recentExecutions[].sharedBlkWriteTimeUs` | `integer` | Yes | — | Time spent writing shared blocks, in microseconds. |
| `result.data.result.recentExecutions[].localBlksHit` | `integer` | Yes | — | Local buffer blocks hit (temp tables). |
| `result.data.result.recentExecutions[].localBlksRead` | `integer` | Yes | — | Local buffer blocks read (temp tables). |
| `result.data.result.recentExecutions[].localBlksWritten` | `integer` | Yes | — | Local buffer blocks written (temp tables). |
| `result.data.result.recentExecutions[].localBlksDirtied` | `integer` | Yes | — | Local buffer blocks dirtied (temp tables). |
| `result.data.result.recentExecutions[].tempBlksRead` | `integer` | Yes | — | Temp blocks read (spills to disk). |
| `result.data.result.recentExecutions[].tempBlksWritten` | `integer` | Yes | — | Temp blocks written (spills to disk). |
| `result.data.result.recentExecutions[].tempBlkReadTimeUs` | `integer` | Yes | — | Time spent reading temp blocks, in microseconds. |
| `result.data.result.recentExecutions[].tempBlkWriteTimeUs` | `integer` | Yes | — | Time spent writing temp blocks, in microseconds. |
| `result.data.result.recentExecutions[].walRecords` | `integer` | Yes | — | Number of WAL records produced. |

The table shows the first 50 fields. Expand the raw schema below for every field.

<Info>
  This output schema is too large to embed without slowing the page. Get the complete live contract with `deepline tools get clickhouse_slow_query_pattern_get --json`.
</Info>

## 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](/docs/providers/clickhouse/guide)
* [SDK V2 quickstart](/docs/sdk-v2/quickstart)
* [SDK reference](/docs/sdk-v2/sdk-reference)
* [Run tools across a CSV](/docs/sdk-v2/batch-csv)


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