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

# List Postgres blocking queries

> **This endpoint is in beta.** API contract is stable, and no breaking changes are expected in the future. <br /><br /> Returns which queries waited on locks held by other queries on a Postgres service during the given time window. Each item groups one waiting query with one direct blocker, most-sampled first. Groups come only from periods when blocking query collection was on for the service; turn it on in the console. Results are paginated with `limit`/`offset` and include `totalCount`. The time range must not exceed 31 days, and `to_date` must be after `from_date`.

Beta

**This endpoint is in beta.** API contract is stable, and no breaking changes are expected in the future. \
\
&#x20;Returns which queries waited on locks held by other queries on a Postgres service during the given time window. Each item groups one waiting query with one direct blocker, most-sampled first. Groups come only from periods when blocking query collection was on for the service; turn it on in the console. Results are paginated with `limit`/`offset` and include `totalCount`. The time range must not exceed 31 days, and `to_date` must be after `from_date`.

#### Permission

The API key must have the `control-plane:postgres-service:view` permission.


## OpenAPI

````yaml _specs/cloud-openapi.json GET /v1/organizations/{organizationId}/postgres/{postgresId}/blockingQueries
openapi: 3.1.1
info:
  title: OpenAPI spec for ClickHouse Cloud
  version: '1.0'
  contact:
    name: ClickHouse Support
    url: >-
      https://clickhouse.com/docs/en/cloud/manage/openapi?referrer=openapi-1513344
    email: support@clickhouse.com
servers:
  - url: https://api.clickhouse.cloud
security:
  - basicAuth: []
tags:
  - name: Organization
  - name: Notifications
  - name: User management
  - name: Billing
  - name: Role Management
  - name: Service
  - name: Backup
  - name: Snapshot
  - name: API keys
  - name: Prometheus
  - name: ClickPipes
  - name: ClickStack
  - name: Postgres
  - name: UDF
  - name: Query API endpoints
  - name: Saved queries
paths:
  /v1/organizations/{organizationId}/postgres/{postgresId}/blockingQueries:
    get:
      tags:
        - Postgres
      summary: List Postgres blocking queries
      description: >-
        **This endpoint is in beta.** API contract is stable, and no breaking
        changes are expected in the future. <br /><br /> Returns which queries
        waited on locks held by other queries on a Postgres service during the
        given time window. Each item groups one waiting query with one direct
        blocker, most-sampled first. Groups come only from periods when blocking
        query collection was on for the service; turn it on in the console.
        Results are paginated with `limit`/`offset` and include `totalCount`.
        The time range must not exceed 31 days, and `to_date` must be after
        `from_date`.
      operationId: postgresBlockingQueriesGetList
      parameters:
        - in: path
          name: organizationId
          description: ID of the organization that owns the Postgres service.
          required: true
          schema:
            type: string
            format: uuid
        - in: path
          name: postgresId
          description: ID of the requested Postgres service.
          required: true
          schema:
            type: string
            format: uuid
        - in: query
          name: from_date
          description: Inclusive start of the time window (RFC 3339 date-time).
          schema:
            type: string
            format: date-time
          required: true
        - in: query
          name: to_date
          description: Inclusive end of the time window (RFC 3339 date-time).
          schema:
            type: string
            format: date-time
          required: true
        - in: query
          name: db_name
          description: Filter to groups whose waiting sessions used this database.
          schema:
            type: string
        - in: query
          name: db_user
          description: Filter to groups whose waiting sessions ran as this database user.
          schema:
            type: string
        - in: query
          name: app
          description: >-
            Filter to groups whose waiting sessions had this `application_name`.
            An empty value matches sessions with no application name.
          schema:
            type: string
        - in: query
          name: limit
          description: Maximum number of results to return.
          schema:
            type: integer
            minimum: 1
            maximum: 2000
            default: 50
        - in: query
          name: offset
          description: Number of results to skip before returning.
          schema:
            type: integer
            minimum: 0
            default: 0
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: number
                    description: HTTP status code.
                    example: 200
                  requestId:
                    type: string
                    description: Unique id assigned to every request. UUIDv4
                    format: uuid
                  result:
                    type: array
                    items:
                      $ref: '#/components/schemas/PostgresBlockingQuery'
        '400':
          description: >-
            The request cannot be processed due to a client error. Please verify
            your request parameters and try again.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: number
                    description: HTTP status code.
                    example: 400
                  error:
                    type: string
                    description: Detailed error description.
                  requestId:
                    type: string
                    description: Unique id assigned to every request. UUIDv4
                    format: uuid
        '500':
          description: >-
            An internal server error has occurred. If this issue persists,
            please contact ClickHouse Cloud support for assistance.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    description: HTTP status code.
                    example: 500
                  error:
                    type: string
                    description: Detailed error description.
                  requestId:
                    type: string
                    description: Unique id assigned to every request. UUIDv4
                    format: uuid
components:
  schemas:
    PostgresBlockingQuery:
      properties:
        database:
          description: Database of the waiting sessions.
          type: string
        blockedQueryId:
          description: >-
            Query ID of the waiting statement, as in slow query patterns. Empty
            when Postgres had none yet; the group is then a single waiting
            session.
          type: string
        blockedQuery:
          description: >-
            Normalized text of the waiting statement from Query Insights. Empty
            when no text is available.
          type: string
        blockedUsers:
          type: array
          description: Database users of the waiting sessions (up to 10).
          items:
            type: string
        blockedApps:
          type: array
          description: >-
            Non-empty `application_name` values of the waiting sessions (up to
            10).
          items:
            type: string
        blockedPids:
          type: array
          description: >-
            Process IDs of the waiting sessions, most recently seen first (up to
            10).
          items:
            type: integer
        lockType:
          description: >-
            Postgres lock type waited on at the latest sample (for example,
            relation, tuple, transactionid, advisory).
          type: string
          example: transactionid
        blockedMode:
          description: >-
            Lock mode requested by the waiting session at the latest sample (for
            example, ShareLock).
          type: string
          example: ShareLock
        blockingDatabase:
          description: Database of the blocking session. Empty for a prepared transaction.
          type: string
        blockingQueryId:
          description: >-
            Query ID of the blocking statement. Empty when the blocker had none;
            the group is then a single blocking session.
          type: string
        blockingQuery:
          description: >-
            Normalized text of the blocking statement from Query Insights. Empty
            when no text is available.
          type: string
        blockingUsers:
          type: array
          description: Database users of the blocking sessions (up to 10).
          items:
            type: string
        blockingApps:
          type: array
          description: >-
            Non-empty `application_name` values of the blocking sessions (up to
            10).
          items:
            type: string
        blockingPids:
          type: array
          description: >-
            Process IDs of the blocking sessions, most recently seen first (up
            to 10). A prepared transaction reports 0.
          items:
            type: integer
        blockingPrepared:
          description: >-
            True when the blocker is a prepared transaction, which has no
            session.
          type: boolean
        blockingInternal:
          description: >-
            True when the blocker is a session the service uses internally, for
            example for monitoring or replication. Its query text is not
            returned.
          type: boolean
        latestBlockingState:
          description: >-
            State of the blocking session at the latest sample (for example,
            active, idle in transaction).
          type: string
          example: idle in transaction
        latestBlockingXactSeconds:
          description: >-
            Age of the blocking transaction at the latest sample, in seconds.
            `null` when not reported, as for a prepared transaction.
          type:
            - number
            - 'null'
        latestBlockingBackendType:
          description: >-
            Postgres backend type of the blocker at the latest sample (for
            example, client backend, autovacuum worker).
          type: string
          example: client backend
        blockingSeenWaiting:
          description: >-
            True when the blocker was itself waiting on a lock in at least one
            sample.
          type: boolean
        sessions:
          description: Number of distinct waiting sessions in the group.
          type: integer
        samples:
          description: Number of samples in which the group was seen.
          type: integer
        longestWaitSeconds:
          description: >-
            Longest observed wait of a waiting session, in seconds. `null` when
            no sample reported how long the session had waited.
          type:
            - number
            - 'null'
        lastSeen:
          description: Time of the latest sample (RFC 3339).
          type: string
          format: date-time
          example: '2026-04-22T14:06:00Z'
      required:
        - database
        - blockedQueryId
        - blockedQuery
        - blockedUsers
        - blockedApps
        - blockedPids
        - lockType
        - blockedMode
        - blockingDatabase
        - blockingQueryId
        - blockingQuery
        - blockingUsers
        - blockingApps
        - blockingPids
        - blockingPrepared
        - blockingInternal
        - latestBlockingState
        - latestBlockingXactSeconds
        - latestBlockingBackendType
        - blockingSeenWaiting
        - sessions
        - samples
        - longestWaitSeconds
        - lastSeen
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: >-
        Use key ID and key secret obtained in ClickHouse Cloud console:
        https://clickhouse.com/docs/cloud/manage/openapi
      x-permission-scopes: >-
        The scope list of a `security` requirement holds ClickHouse Cloud API
        key permission ids (for example `control-plane:organization:view`), not
        OAuth scopes. OpenAPI has no field for API key permissions, so this is
        the closest available place. A key must hold every permission listed on
        an operation to call it; an operation with no scopes needs none beyond a
        valid key. Every operation declares at most one requirement object,
        always for this scheme, so the list is only ever conjunctive —
        alternative sets of permissions are never expressed.

````