> ## 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 Slow Query Patterns Get List: Inputs, Cost &

> List Postgres slow query patterns. Includes inputs, outputs, pricing notes, Deepline CLI examples, and GTM automation guidance.

## Run in Enrichment Spreadsheet

<Info>
  Use this function as a column step in `deepline enrich`.
</Info>

```bash theme={null}
deepline enrich --input leads.csv --output leads.enriched.csv --with 'result=clickhouse_slow_query_patterns_get_list:{"organizationId":"{{organizationId}}","postgresId":"{{postgresId}}","from_date":"{{from_date}}","to_date":"{{to_date}}"}' --json
```

<Tip>
  Map payload values to spreadsheet columns with `{{column_name}}` placeholders.
</Tip>

## Input Schema

| Name                     | Type                                                                                                                                                                                                                                                   | Required | Default            | Description                                                                       |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- | ------------------ | --------------------------------------------------------------------------------- |
| `payload.organizationId` | `string`                                                                                                                                                                                                                                               | Yes      |                    | ID of the organization that owns the Postgres service.                            |
| `payload.postgresId`     | `string`                                                                                                                                                                                                                                               | Yes      |                    | ID of the requested Postgres service.                                             |
| `payload.from_date`      | `string`                                                                                                                                                                                                                                               | Yes      |                    | Inclusive start of the time window (RFC 3339 date-time).                          |
| `payload.to_date`        | `string`                                                                                                                                                                                                                                               | Yes      |                    | Exclusive end of the time window (RFC 3339 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.                                                         |
| `payload.sort_order`     | `"asc" \| "desc"`                                                                                                                                                                                                                                      | No       | `"desc"`           | Sort order. One of `asc` or `desc`.                                               |
| `payload.limit`          | `integer`                                                                                                                                                                                                                                              | No       | `20`               | Maximum number of results to return.                                              |
| `payload.offset`         | `integer`                                                                                                                                                                                                                                              | No       | `0`                | Number of results to skip before returning.                                       |

### Allowed values

| Field                | Allowed values                                                                                                                                                                                                               |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `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` |
| `payload.sort_order` | `asc`, `desc`                                                                                                                                                                                                                |

<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 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 Schema

| Name          | Type     | Required | Default | Description                                    |
| ------------- | -------- | -------- | ------- | ---------------------------------------------- |
| `result.data` | `object` | Yes      |         | Provider response payload.                     |
| `result.meta` | `object` | No       |         | Additional response metadata (status, paging). |

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

  ### Output JSON Schema

  ```json theme={null}
  {
    "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>

## Advanced: Direct CLI

<Info>
  Use direct execution for single payload debugging.
</Info>

```bash theme={null}
deepline tools execute clickhouse_slow_query_patterns_get_list --payload '{
  "organizationId": "string",
  "postgresId": "string",
  "from_date": "string",
  "to_date": "string"
}' --json
```

### CLI flags

| Flag                        | Description                                         |
| --------------------------- | --------------------------------------------------- |
| `--json`                    | Print machine-readable output.                      |
| `--wait`                    | Wait for terminal provider status when supported.   |
| `--debug`                   | Enable wait mode with additional status/log output. |
| `--wait-timeout SECONDS`    | Max seconds to wait in wait mode.                   |
| `--poll-interval SECONDS`   | Polling interval in seconds during wait mode.       |
| `--timeout SECONDS`         | Request timeout in seconds.                         |
| `--connect-timeout SECONDS` | Connection timeout in seconds.                      |

## Cost

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