# Clickhouse Managed Postgres Rca > MUST USE when investigating performance issues on a ClickHouse-managed Postgres instance. Provides an evidence-based RCA workflow that scrapes the Prometheus endpoint for system signal, pulls per-digest evidence from the Slow Query Patterns API, and recommends (does not apply) a fix. Fuente: https://skillsagentes.com/skills/clickhouse/agent-skills/clickhouse-managed-postgres-rca Markdown: https://skillsagentes.com/skills/clickhouse/agent-skills/clickhouse-managed-postgres-rca.md Repositorio: https://github.com/ClickHouse/agent-skills Autor: ClickHouse Licencia: Apache-2.0 Actualizado: hace 2 meses Coste de contexto: 71 tok instalada, 1.2k tok al activarse, 17.7k tok con todos los archivos del bundle Bundle: 13 archivos, 69 KB Permisos que pide: ninguno declarado ## Instalación Un skill son archivos markdown: los mismos archivos valen para cualquier agente y lo único que cambia es el directorio de destino, es decir la bandera `--agent`. Añade `-g` para instalarlo en todos los proyectos de la máquina. ```bash # Claude Code npx -y skills add ClickHouse/agent-skills --skill clickhouse-managed-postgres-rca --agent claude-code # Cursor npx -y skills add ClickHouse/agent-skills --skill clickhouse-managed-postgres-rca --agent cursor # Codex npx -y skills add ClickHouse/agent-skills --skill clickhouse-managed-postgres-rca --agent codex # Gemini CLI npx -y skills add ClickHouse/agent-skills --skill clickhouse-managed-postgres-rca --agent gemini # Windsurf npx -y skills add ClickHouse/agent-skills --skill clickhouse-managed-postgres-rca --agent windsurf # Cline npx -y skills add ClickHouse/agent-skills --skill clickhouse-managed-postgres-rca --agent cline ``` ## Archivos - AGENTS.md — 32 KB - README.md — 1 KB - SKILL.md — 5 KB - metadata.json — 887 B - rules/heuristic-full-scan.md — 2 KB - rules/heuristic-hot-loop.md — 2 KB - rules/heuristic-write-congestion.md — 3 KB - rules/openapi-discovery.md — 6 KB - rules/output-template.md — 3 KB - rules/prometheus-scrape.md — 4 KB - rules/recommend-only.md — 2 KB - rules/slow-query-patterns-fields.md — 5 KB - rules/triage.md — 3 KB ## SKILL.md Reproducido tal cual desde ClickHouse/agent-skills bajo Apache-2.0. Esta sección es el documento original y está en inglés. # ClickHouse Managed Postgres RCA ## When to use Trigger whenever a user reports slowness, high CPU, low throughput, cache thrash, or any unexplained pain on a ClickHouse-managed Postgres instance. ## What you have access to Two APIs on `https://api.clickhouse.cloud` (HTTP Basic auth using a ClickHouse Cloud API key/secret pair): - **Prometheus metrics** — operation `postgresInstancePrometheusGet` under the Prometheus tag. Returns Prometheus exposition format. System and workload metrics for one Postgres service. - **Slow Query Patterns** — operation `slowQueryPatternsGetList` under the Postgres tag. Returns per-digest latency, IO, and call statistics for normalized query patterns. **Beta.** Both endpoints require an `organizationId` and a `serviceId` as path parameters. The user must supply both, plus the API key/secret pair. ## What you do NOT have - Query plans / EXPLAIN output. - Per-table scan-type counters (`seq_scan` / `idx_scan`). - Autovacuum or last-ANALYZE timestamps. Reason from IO and timing signals, not from a plan tree. ## Workflow Six steps, in order. Do not skip ahead. Steps 2 and 3 only share auth — no data dependency between them. Run them in parallel (background curls, `&` + `wait`) to cut wall time from sequential ~2s to ~1s. ### 1. Discover the live API shape These endpoints are Beta — paths, params, and JSON field names can shift. Follow `rules/openapi-discovery.md` to: 1. Fetch the OpenAPI spec from `https://api.clickhouse.cloud/v1`. 2. Locate the two operations by `operationId`: - `postgresInstancePrometheusGet` (Prometheus tag) - `slowQueryPatternsGetList` (Postgres tag) 3. Resolve their path templates, required query parameters, and (for the slow-query endpoint) the response schema. 4. Build a session-scoped role map from the schema property descriptions: `{ semantic role → actual field name }`. Use the resolved names in every subsequent request and citation. Never hardcode field names from memory. ### 2. Scrape Prom once for system gauges Follow `rules/prometheus-scrape.md`. **One scrape, no wait.** You're after gauges (current values) that don't need a delta: `CacheHitRatio`, `ActiveConnections`, `MemoryUsedPercent`, `FilesystemUsedPercent`. A `CacheHitRatio` well below ~95% on a workload that should fit in cache is a real signal on its own. Climbing `ActiveConnections` toward the pool ceiling is a real signal on its own. These don't need rate-of-change. A second scrape for counter deltas is **opt-in**, used only when Step 4 triage points at write-congestion (where deadlock and rollback *rates* matter and the Slow Query Patterns API can't substitute). For the read-path case (the most common RCA shape) the single scrape is enough. ### 3. Pull top slow query patterns Request the slow query patterns. Follow `rules/slow-query-patterns-fields.md` for the fields that matter and how to read them. This is the primary diagnostic — it returns per-pattern accumulated totals (call count, runtime, blocks, rows) over the window you request, which is the "rate-of-change" data you'd otherwise derive from two Prom scrapes — but per query and without waiting. If no patterns return a meaningful `totalDurationUs`, the report may be overstated or the issue isn't query-shaped. Stop and tell the user what you looked at. ### 4. Triage: pick the right heuristic Follow `rules/triage.md`. Match the combined Prom + slow-query signal to one of the heuristic shapes. Each shape points to a specific heuristic file: - `rules/heuristic-full-scan.md` — read-path full scan. - `rules/heuristic-hot-loop.md` — N+1 / hot loop from the app. - `rules/heuristic-write-congestion.md` — deadlocks, slow writes, high rollback rate. If the signal does not match any shape cleanly, do not invent a hypothesis. Surface the top patterns and ask the user which workload they recognize. New heuristics are welcome as PRs. ### 5. Reason, then recommend Use the format in `rules/output-template.md`. Always include: symptom, evidence, hypothesis (noting any alternative cause you cannot rule out from this surface alone), short-term fix, and long-term follow-ups. ### 6. Do not apply the fix Follow `rules/recommend-only.md`. Never run DDL. Never call `pg_cancel_backend` or `pg_terminate_backend`. Write the recommendation, explain why, and let the human apply it. ## Full Compiled Document For the complete guide with every rule expanded in a single context load: `AGENTS.md`. ## Dónde encaja - Categoría: [Bases de datos](https://skillsagentes.com/categorias/bases-de-datos.md) — Diseño de esquemas, migraciones y optimización de consultas. - Creador: [ClickHouse](https://skillsagentes.com/creators/clickhouse.md) — 11 skills en el directorio - [Todas las skills](https://skillsagentes.com/skills.md) - [Ranking de instalaciones](https://skillsagentes.com/ranking.md) ## Otras skills del mismo repositorio - [Clickhouse Js Node Rowbinary](https://skillsagentes.com/skills/clickhouse/agent-skills/clickhouse-js-node-rowbinary.md): Generate TypeScript/JavaScript code that reads/decodes AND writes/encodes ClickHouse RowBinary streams for the ClickHouse HTTP server. Use this skill whenever a user wants to parse or produce `RowBinary`, `RowBinaryWithNames`, or `RowBinaryWithNamesAndTypes`. Node.js only, doesn't cover browsers. - [Infra Postgres](https://skillsagentes.com/skills/clickhouse/agent-skills/infra-postgres.md): Sets up and manages Postgres using the clickhousectl CLI — runs a local Docker-backed Postgres for development, and creates and operates managed ClickHouse Cloud Postgres services (connections, TLS, runtime config, read replicas, failover, point-in-time restore). Use when the user wants a Postgres or PostgreSQL database for their application, a local Postgres dev environment, psql access, or a managed/production Postgres in ClickHouse Cloud, or mentions moving a local Postgres to production. - [Infra Clickhouse](https://skillsagentes.com/skills/clickhouse/agent-skills/infra-clickhouse.md): Sets up and manages ClickHouse using the clickhousectl CLI — installs and runs a local ClickHouse server for development, and creates managed ClickHouse Cloud services for production (authentication, service creation, schema migration, application connection). Use when the user wants to build an application with ClickHouse, set up a local ClickHouse dev environment, create tables and start querying, deploy ClickHouse to production or ClickHouse Cloud, or migrate from a local setup to the cloud. - [Clickstack Otel Collector](https://skillsagentes.com/skills/clickhouse/agent-skills/clickstack-otel-collector.md): Use when a user wants to wire an OpenTelemetry collector into a Managed ClickStack service on ClickHouse Cloud, either by deploying a new local collector (Docker run or Docker Compose) or by configuring their own existing collector, then send rich synthetic telemetry and verify it is visible in ClickStack. - [Clickhouse Js Node Coding](https://skillsagentes.com/skills/clickhouse/agent-skills/clickhouse-js-node-coding.md): Write idiomatic application code with the ClickHouse Node.js client (`@clickhouse/client`). Use this skill whenever a user is *building* against the Node.js client — configuring the client, pinging, inserting rows in JSON or raw formats, selecting and parsing results, binding query parameters, managing sessions and temporary tables, working with data types or customizing JSON parsing. Do NOT use for browser/Web client code. ## Skills relacionadas - [Chdb Datastore](https://skillsagentes.com/skills/clickhouse/agent-skills/chdb-datastore.md): Use when the user has tabular data (pandas DataFrame, parquet, csv, Arrow, json) and wants to filter, group, aggregate, join, or speed up slow pandas. Provides chDB DataStore — same pandas API, ClickHouse engine underneath. Also handles reading from S3, MySQL, PostgreSQL, MongoDB, ClickHouse Cloud, Iceberg, Delta Lake as DataFrames and joining across sources. TRIGGER when: user mentions DataFrame, parquet, csv, "fast pandas", "speed up pandas", or cross-source DataFrame joins; user imports `chdb.datastore` or `from datastore import DataStore`. SKIP this skill for raw SQL syntax (use chdb-sql instead), ClickHouse server administration, or non-Python DataStore API work. - [Chdb Sql](https://skillsagentes.com/skills/clickhouse/agent-skills/chdb-sql.md): Use when the user wants to run SQL — especially analytical SQL — on local files (parquet/csv/json), URLs, S3 paths, or remote databases (Postgres, MySQL, MongoDB, ClickHouse Cloud, Iceberg, Delta Lake) without setting up a server. Provides chDB — embedded ClickHouse SQL in Python with 1000+ functions, Session for stateful multi-step pipelines, parametrized queries, and cross-source joins via `s3()`, `mysql()`, `postgresql()`, `iceberg()`, `deltaLake()`, `remoteSecure()` table functions. TRIGGER when: user wants SQL on parquet/csv/files or across remote analytical sources; uses ClickHouse SQL features (window functions, windowFunnel, geoToH3, JSON path ops, Session, parametrized queries); imports `chdb` or calls `chdb.query()`. SKIP this skill for pandas-style DataFrame method-chaining (use chdb-datastore instead) or ClickHouse server administration. - [Clickhouse Architecture Advisor](https://skillsagentes.com/skills/clickhouse/agent-skills/clickhouse-architecture-advisor.md): MUST USE when designing ClickHouse architectures, selecting between ingestion or modeling patterns, or translating best practices into workload-specific system designs. Complements clickhouse-best-practices with decision frameworks and explicit provenance labels. - [Clickhouse Best Practices](https://skillsagentes.com/skills/clickhouse/agent-skills/clickhouse-best-practices.md): MUST USE when reviewing ClickHouse schemas, queries, or configurations. Contains 31 rules that MUST be checked before providing recommendations. Always read relevant rule files and cite specific rules in responses. - [Clickhouse Js Node Coding](https://skillsagentes.com/skills/clickhouse/agent-skills/clickhouse-js-node-coding.md): Write idiomatic application code with the ClickHouse Node.js client (`@clickhouse/client`). Use this skill whenever a user is *building* against the Node.js client — configuring the client, pinging, inserting rows in JSON or raw formats, selecting and parsing results, binding query parameters, managing sessions and temporary tables, working with data types or customizing JSON parsing. Do NOT use for browser/Web client code. --- Skills Agentes · [Índice de páginas en markdown](https://skillsagentes.com/sitemap.md) · [Inicio](https://skillsagentes.com/index.md)