Prerequisites
- Docker and Docker Compose
- The pg_stat_ch repository cloned locally
Setup
Start the stack
From the repository root:This starts PostgreSQL (with pg_stat_ch pre-loaded) and ClickHouse with the full schema applied. See
docker/quickstart/ for stack details.Flush events to ClickHouse
Events are flushed automatically every 200ms, but you can trigger an immediate flush:
Check extension health
Back in PostgreSQL, verify the extension is working:enqueued_eventsshould be increasing as you run queriesdropped_eventsshould be 0 (events are being processed faster than produced)exported_eventsshould match or be close toenqueued_eventssend_failuresshould be 0
Try a latency percentile query
Use the pre-aggregated materialized view to get p95/p99 latencies:Tear down
Next steps
ClickHouse setup
Production ClickHouse deployment and schema
Configuration
Tune queue size, flush interval, and connection settings
Monitoring queries
Practical query recipes for common use cases
Events schema
Every field in the events_raw table explained

