pg_stat_ch
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_stat_ch | 0.3.6 | STAT | Apache-2.0 | C++ |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 6020 | pg_stat_ch | No | Yes | Yes | Yes | No | No | - |
| Related | pg_tracing pg_stat_monitor pg_stat_kcache powa |
|---|
release 0.3.6; SQL v0.1
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.3.6 | 1817161514 | pg_stat_ch | - |
| RPM | PIGSTY | 0.3.6 | 1817161514 | pg_stat_ch_$v | - |
| DEB | PIGSTY | 0.3.6 | 1817161514 | postgresql-$v-pg-stat-ch | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| el8.aarch64 | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| el9.x86_64 | PIGSTY 0.3.6 el9.x86_64.pg18 : pg_stat_ch_18 pg_stat_ch_18-0.3.6-1PIGSTY.el9.x86_64.rpm
| PIGSTY 0.3.6 el9.x86_64.pg17 : pg_stat_ch_17 pg_stat_ch_17-0.3.6-1PIGSTY.el9.x86_64.rpm
| PIGSTY 0.3.6 el9.x86_64.pg16 : pg_stat_ch_16 pg_stat_ch_16-0.3.6-1PIGSTY.el9.x86_64.rpm
| PIGSTY MISS | PIGSTY MISS |
| el9.aarch64 | PIGSTY 0.3.6 el9.aarch64.pg18 : pg_stat_ch_18 pg_stat_ch_18-0.3.6-1PIGSTY.el9.aarch64.rpm
| PIGSTY 0.3.6 el9.aarch64.pg17 : pg_stat_ch_17 pg_stat_ch_17-0.3.6-1PIGSTY.el9.aarch64.rpm
| PIGSTY 0.3.6 el9.aarch64.pg16 : pg_stat_ch_16 pg_stat_ch_16-0.3.6-1PIGSTY.el9.aarch64.rpm
| PIGSTY MISS | PIGSTY MISS |
| el10.x86_64 | PIGSTY 0.3.6 el10.x86_64.pg18 : pg_stat_ch_18 pg_stat_ch_18-0.3.6-1PIGSTY.el10.x86_64.rpm
| PIGSTY 0.3.6 el10.x86_64.pg17 : pg_stat_ch_17 pg_stat_ch_17-0.3.6-1PIGSTY.el10.x86_64.rpm
| PIGSTY 0.3.6 el10.x86_64.pg16 : pg_stat_ch_16 pg_stat_ch_16-0.3.6-1PIGSTY.el10.x86_64.rpm
| PIGSTY MISS | PIGSTY MISS |
| el10.aarch64 | PIGSTY 0.3.6 el10.aarch64.pg18 : pg_stat_ch_18 pg_stat_ch_18-0.3.6-1PIGSTY.el10.aarch64.rpm
| PIGSTY 0.3.6 el10.aarch64.pg17 : pg_stat_ch_17 pg_stat_ch_17-0.3.6-1PIGSTY.el10.aarch64.rpm
| PIGSTY 0.3.6 el10.aarch64.pg16 : pg_stat_ch_16 pg_stat_ch_16-0.3.6-1PIGSTY.el10.aarch64.rpm
| PIGSTY MISS | PIGSTY MISS |
| d12.x86_64 | PIGSTY 0.3.6 d12.x86_64.pg18 : postgresql-18-pg-stat-ch postgresql-18-pg-stat-ch_0.3.6-1PIGSTY~bookworm_amd64.deb
| PIGSTY 0.3.6 d12.x86_64.pg17 : postgresql-17-pg-stat-ch postgresql-17-pg-stat-ch_0.3.6-1PIGSTY~bookworm_amd64.deb
| PIGSTY 0.3.6 d12.x86_64.pg16 : postgresql-16-pg-stat-ch postgresql-16-pg-stat-ch_0.3.6-1PIGSTY~bookworm_amd64.deb
| PIGSTY MISS | PIGSTY MISS |
| d12.aarch64 | PIGSTY 0.3.6 d12.aarch64.pg18 : postgresql-18-pg-stat-ch postgresql-18-pg-stat-ch_0.3.6-1PIGSTY~bookworm_arm64.deb
| PIGSTY 0.3.6 d12.aarch64.pg17 : postgresql-17-pg-stat-ch postgresql-17-pg-stat-ch_0.3.6-1PIGSTY~bookworm_arm64.deb
| PIGSTY 0.3.6 d12.aarch64.pg16 : postgresql-16-pg-stat-ch postgresql-16-pg-stat-ch_0.3.6-1PIGSTY~bookworm_arm64.deb
| PIGSTY MISS | PIGSTY MISS |
| d13.x86_64 | PIGSTY 0.3.6 d13.x86_64.pg18 : postgresql-18-pg-stat-ch postgresql-18-pg-stat-ch_0.3.6-1PIGSTY~trixie_amd64.deb
| PIGSTY 0.3.6 d13.x86_64.pg17 : postgresql-17-pg-stat-ch postgresql-17-pg-stat-ch_0.3.6-1PIGSTY~trixie_amd64.deb
| PIGSTY 0.3.6 d13.x86_64.pg16 : postgresql-16-pg-stat-ch postgresql-16-pg-stat-ch_0.3.6-1PIGSTY~trixie_amd64.deb
| PIGSTY MISS | PIGSTY MISS |
| d13.aarch64 | PIGSTY 0.3.6 d13.aarch64.pg18 : postgresql-18-pg-stat-ch postgresql-18-pg-stat-ch_0.3.6-1PIGSTY~trixie_arm64.deb
| PIGSTY 0.3.6 d13.aarch64.pg17 : postgresql-17-pg-stat-ch postgresql-17-pg-stat-ch_0.3.6-1PIGSTY~trixie_arm64.deb
| PIGSTY 0.3.6 d13.aarch64.pg16 : postgresql-16-pg-stat-ch postgresql-16-pg-stat-ch_0.3.6-1PIGSTY~trixie_arm64.deb
| PIGSTY MISS | PIGSTY MISS |
| u22.x86_64 | PIGSTY 0.3.6 u22.x86_64.pg18 : postgresql-18-pg-stat-ch postgresql-18-pg-stat-ch_0.3.6-1PIGSTY~jammy_amd64.deb
| PIGSTY 0.3.6 u22.x86_64.pg17 : postgresql-17-pg-stat-ch postgresql-17-pg-stat-ch_0.3.6-1PIGSTY~jammy_amd64.deb
| PIGSTY 0.3.6 u22.x86_64.pg16 : postgresql-16-pg-stat-ch postgresql-16-pg-stat-ch_0.3.6-1PIGSTY~jammy_amd64.deb
| PIGSTY MISS | PIGSTY MISS |
| u22.aarch64 | PIGSTY 0.3.6 u22.aarch64.pg18 : postgresql-18-pg-stat-ch postgresql-18-pg-stat-ch_0.3.6-1PIGSTY~jammy_arm64.deb
| PIGSTY 0.3.6 u22.aarch64.pg17 : postgresql-17-pg-stat-ch postgresql-17-pg-stat-ch_0.3.6-1PIGSTY~jammy_arm64.deb
| PIGSTY 0.3.6 u22.aarch64.pg16 : postgresql-16-pg-stat-ch postgresql-16-pg-stat-ch_0.3.6-1PIGSTY~jammy_arm64.deb
| PIGSTY MISS | PIGSTY MISS |
| u24.x86_64 | PIGSTY 0.3.6 u24.x86_64.pg18 : postgresql-18-pg-stat-ch postgresql-18-pg-stat-ch_0.3.6-1PIGSTY~noble_amd64.deb
| PIGSTY 0.3.6 u24.x86_64.pg17 : postgresql-17-pg-stat-ch postgresql-17-pg-stat-ch_0.3.6-1PIGSTY~noble_amd64.deb
| PIGSTY 0.3.6 u24.x86_64.pg16 : postgresql-16-pg-stat-ch postgresql-16-pg-stat-ch_0.3.6-1PIGSTY~noble_amd64.deb
| PIGSTY MISS | PIGSTY MISS |
| u24.aarch64 | PIGSTY 0.3.6 u24.aarch64.pg18 : postgresql-18-pg-stat-ch postgresql-18-pg-stat-ch_0.3.6-1PIGSTY~noble_arm64.deb
| PIGSTY 0.3.6 u24.aarch64.pg17 : postgresql-17-pg-stat-ch postgresql-17-pg-stat-ch_0.3.6-1PIGSTY~noble_arm64.deb
| PIGSTY 0.3.6 u24.aarch64.pg16 : postgresql-16-pg-stat-ch postgresql-16-pg-stat-ch_0.3.6-1PIGSTY~noble_arm64.deb
| PIGSTY MISS | PIGSTY MISS |
Build
You can build the RPM / DEB packages for pg_stat_ch using pig build:
pig build pkg pg_stat_ch # build RPM / DEB packages
Install
You can install pg_stat_ch directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install pg_stat_ch; # Install for current active PG version
pig ext install -y pg_stat_ch -v 18 # PG 18
pig ext install -y pg_stat_ch -v 17 # PG 17
pig ext install -y pg_stat_ch -v 16 # PG 16
dnf install -y pg_stat_ch_18 # PG 18
dnf install -y pg_stat_ch_17 # PG 17
dnf install -y pg_stat_ch_16 # PG 16
apt install -y postgresql-18-pg-stat-ch # PG 18
apt install -y postgresql-17-pg-stat-ch # PG 17
apt install -y postgresql-16-pg-stat-ch # PG 16
Preload:
shared_preload_libraries = 'pg_stat_ch';
Create Extension:
CREATE EXTENSION pg_stat_ch;
Usage
Sources: README, release 0.3.6
pg_stat_ch captures per-query PostgreSQL execution telemetry and exports raw events to ClickHouse through a shared-memory queue and background worker. The upstream project positions it as a raw-event alternative to pg_stat_statements, with aggregation and dashboards handled in ClickHouse instead of PostgreSQL.
CREATE EXTENSION pg_stat_ch;
Required Setup
pg_stat_ch must be preloaded and pointed at a ClickHouse database:
shared_preload_libraries = 'pg_stat_ch'
track_io_timing = on
pg_stat_ch.clickhouse_host = 'localhost'
pg_stat_ch.clickhouse_port = 9000
pg_stat_ch.clickhouse_database = 'pg_stat_ch'
pg_stat_ch.clickhouse_use_tls = on
pg_stat_ch.clickhouse_skip_tls_verify = off
The README says PostgreSQL 16, 17, and 18 are fully supported; the latest release is 0.3.6 from April 15, 2026.
SQL API
pg_stat_ch_version()returns the extension version.pg_stat_ch_stats()exposes queue and exporter counters.pg_stat_ch_reset()clears queue counters.pg_stat_ch_flush()triggers an immediate export flush.
SELECT pg_stat_ch_version();
SELECT * FROM pg_stat_ch_stats();
SELECT pg_stat_ch_flush();
Important GUCs
pg_stat_ch.enabledtoggles collection.pg_stat_ch.queue_capacityandpg_stat_ch.string_area_sizesize the shared-memory buffers.pg_stat_ch.flush_interval_msandpg_stat_ch.batch_maxcontrol exporter cadence and batch size.pg_stat_ch.log_min_elevelcontrols which errors are captured.
What Gets Captured
- Query timing, row counts, buffer usage, WAL usage, and CPU time.
- DML, DDL, and utility statements.
- SQLSTATE and error levels.
- JIT metrics on PostgreSQL 15+.
- Parallel worker stats on PostgreSQL 18+.
- Application name, client IP, and query text up to the upstream truncation limit.
Caveats
- The design intentionally drops events on queue overflow instead of blocking the foreground query path.
- ClickHouse schema creation is a required part of setup; upstream quickstart scripts preload it automatically, but manual deployments must load the schema separately.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.