---
title: "List branch queries"
method: GET
path: "/organizations/{organization}/databases/{database}/branches/{branch}/insights"
tags: ["api-query_insights"]
---

# List branch queries

`GET /organizations/{organization}/databases/{database}/branches/{branch}/insights`

### Authorization
A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:

**Service Token Accesses**
 `read_databases`, `read_database`

**OAuth Scopes**

 | Resource | Scopes |
| :------- | :---------- |
| Organization | `read_databases` |
| Database | `read_database` |

## Path parameters

- `organization` string, required
- `database` string, required
- `branch` string, required

## Query parameters

- `q` string
- `from` string
- `to` string
- `period` '15m' | '1h' | '3h' | '6h' | '12h' | '1d' | '2d' | '7d' | '8d'
- `sort` 'keyspace' | 'query' | 'lastRun' | 'count' | 'errorCount' | 'rowsRead' | 'rowsAffected' | 'rowsReturned' | 'rowsReadPerReturned' | 'rowsReadPerQuery' | 'rowsReturnedPerQuery' | 'rowsAffectedPerQuery' | 'totalTime' | 'cpuTime' | 'ioTime' | 'sumShardQueries' | 'maxShardQueries' | 'avgShardQueries' | 'avgParallelWorkers' | 'table' | 'qualifiedTable' | 'tableKeyspace' | 'indexes' | 'routingIndexes' | 'p50Latency' | 'p99Latency' | 'maxLatency' | 'percentTime' | 'percentCpuTime' | 'percentIoTime' | 'egressBytes' | 'egressBytesPerQuery' | 'maxEgressBytes' | 'ingressBytes' | 'ingressBytesPerQuery' | 'maxIngressBytes' | 'blocksRead' | 'blocksHit' | 'blockCacheHitRatio' | 'blocksDirtied' | 'blocksWritten' | 'trafficControlWarnings' | 'trafficControlThrottled' | 'trafficControlChecked' | 'trafficControlBudgetsUsed'
- `dir` 'asc' | 'desc'
- `tablet_type` 'primary' | 'replica' | 'rdonly'
- `type` 'SELECT' | 'INSERT' | 'UPDATE' | 'DELETE'
- `fields` string[]
- `page` integer
- `per_page` integer

## Response `200`

Returns query statistics summaries

- object
  - `type` string, required — The response type. Always "list" for paginated responses.
  - `current_page` integer, required — The current page number
  - `per_page` integer, required — The maximum number of results per page
  - `next_page` integer, nullable, required — The next page number, or null when this is the last page
  - `next_page_url` string, nullable, required — The next page of results, or null when this is the last page
  - `prev_page` integer, nullable, required — The previous page number, or null when this is the first page
  - `prev_page_url` string, nullable, required — The previous page of results, or null when this is the first page
  - `data` object[], required
    - `id` string, required — The ID of the query summary
    - `fingerprint` string, required — The query fingerprint
    - `statement_type` string, required — The type of SQL statement
    - `keyspace` string, required — The keyspace the query ran against
    - `normalized_sql` string, required — The normalized SQL statement
    - `syntax_highlighted_sql` string, required — Syntax highlighted SQL statement
    - `multishard` boolean, required — Whether the query is a multishard query
    - `query_count` integer, required — The number of times this query was executed
    - `error_count` integer, required — The number of times this query resulted in an error
    - `tables` string[], required — Tables accessed by the query
    - `qualified_tables` string[], required — Fully qualified tables accessed by the query
    - `table_keyspaces` object[], required — Mapping of tables to their keyspaces
    - `index_usages` object[], required — Index usage information
    - `routing_index_usages` object[], required — Routing index usage information
    - `sum_shard_queries` integer, required — The total number of shard queries
    - `max_shard_queries` integer, required — The maximum number of shard queries for a single execution
    - `avg_shard_queries` number, required — The average number of shard queries
    - `avg_parallel_workers` number, required — The average number of parallel workers
    - `sum_rows_read` integer, required — The total number of rows read
    - `sum_rows_affected` integer, required — The total number of rows affected
    - `sum_rows_returned` integer, required — The total number of rows returned
    - `rows_read_per_returned` number, required — Average rows read per row returned
    - `rows_read_per_query` number, required — Average rows read per query
    - `rows_returned_per_query` number, required — Average rows returned per query
    - `rows_affected_per_query` number, required — Average rows affected per query
    - `sum_total_duration_millis` integer, required — Total duration in milliseconds across all executions
    - `sum_total_duration_percent` number, required — Percentage of total query time
    - `sum_cpu_duration_millis` integer, required — Total CPU duration in milliseconds
    - `sum_cpu_duration_percent` number, required — Percentage of total CPU time
    - `sum_io_duration_millis` integer, required — Total IO duration in milliseconds
    - `sum_io_duration_percent` number, required — Percentage of total IO time
    - `last_run_at` string, nullable, required — When this query was last executed
    - `time_per_query` number, required — Average time per query execution
    - `p50_latency` number, required — 50th percentile latency
    - `p99_latency` number, required — 99th percentile latency
    - `max_latency` number, required — Maximum latency observed
    - `egress_bytes` integer, required — Total egress bytes
    - `egress_bytes_per_query` number, required — Average egress bytes per query
    - `max_egress_bytes` integer, required — Maximum egress bytes for a single execution
    - `ingress_bytes` integer, required — Total ingress bytes
    - `ingress_bytes_per_query` number, required — Average ingress bytes per query
    - `max_ingress_bytes` integer, required — Maximum ingress bytes for a single execution
    - `blocks_read` integer, required — Total blocks read from disk
    - `blocks_hit` integer, required — Total blocks found in cache
    - `block_cache_hit_ratio` number, required — Cache hit ratio for blocks
    - `blocks_dirtied` integer, required — Total blocks dirtied
    - `blocks_written` integer, required — Total blocks written
    - `traffic_control_warnings` integer, required — The number of executions that triggered a traffic control warning
    - `traffic_control_throttled` integer, required — The number of executions throttled by traffic control
    - `traffic_control_checked` integer, required — The number of executions checked by traffic control rules

## Other responses

- `400` — Invalid time range
- `401` — Unauthorized
- `403` — Forbidden
- `404` — Not Found
- `500` — Internal Server Error

## Changes

- **2026-08-28** `6d28c038c4fd` — 1 info
  - added the non-success response with the status `400`
- **2026-08-11** `4b2e4f05bda2` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/planetscale/apis/planetscale-api/changes/organizations/:organization/databases/:database/branches/:branch/insights/get.md)

---

[API](https://skmtc.dev/planetscale/apis/planetscale-api.md) · [All operations](https://skmtc.dev/planetscale/apis/planetscale-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/planetscale/planetscale-api/revisions/6d28c038c4fd/schema)
