Skip to main content
The events_raw table in ClickHouse stores one row per query execution. This page documents every column with its type, what it means, and when the value is useful for diagnosis. The table is partitioned by date (toDate(ts_start)) and ordered by ts_start for efficient time-range scans.

Timing

ColumnTypeDescription
ts_startDateTime64(6, 'UTC')Query start timestamp with microsecond precision. Used for time-range filtering, partitioning, and correlating events across systems.
duration_usUInt64Total execution time in microseconds. Compare with p95/p99 from the query_stats_5m materialized view to identify outliers.

Identity

ColumnTypeDescription
dbLowCardinality(String)PostgreSQL database name.
usernameLowCardinality(String)PostgreSQL user or role that executed the query.
pidInt32Backend process ID. Correlate with pg_stat_activity for session-level debugging.
query_idInt6464-bit hash of the normalized query. Queries that differ only in literal constants share the same query_id. This is how you group “the same query” across executions. Requires compute_query_id = on in PostgreSQL.
cmd_typeLowCardinality(String)Command type: SELECT, INSERT, UPDATE, DELETE, MERGE, UTILITY, NOTHING, or UNKNOWN. Use for workload characterization (read-heavy vs write-heavy).
rowsUInt64Rows returned (SELECT) or affected (INSERT/UPDATE/DELETE). Unexpectedly high values may indicate a missing WHERE clause.
queryStringQuery text, truncated to 2 KB. Literal constants are replaced with $1, $2, … placeholders to prevent sensitive data from being exported.
Query normalization replaces literals with placeholders ($N). This means SELECT * FROM users WHERE id = 42 becomes SELECT * FROM users WHERE id = $1. No passwords, tokens, or PII are exported in query text.

Shared buffer usage

These columns show how queries interact with PostgreSQL’s shared_buffers cache. The cache hit ratio for a query is shared_blks_hit / (shared_blks_hit + shared_blks_read). Target above 99% for OLTP workloads.
ColumnTypeDescription
shared_blks_hitInt64Blocks found in the shared buffer cache. High values mean the data was already cached.
shared_blks_readInt64Blocks read from disk (cache miss). High values indicate cold data or a working set larger than shared_buffers.
shared_blks_dirtiedInt64Blocks modified by this query. High values mean write-heavy queries that create checkpoint pressure.
shared_blks_writtenInt64Blocks written directly to disk by this backend (not by the background writer or checkpointer). Ideally zero; high values mean the background writer is falling behind. Consider increasing bgwriter_lru_maxpages.

Local buffer usage

Local buffers are used for temporary tables (CREATE TEMP TABLE). They are session-private and do not benefit from shared_buffers.
ColumnTypeDescription
local_blks_hitInt64Temp table blocks found in the session’s local buffer cache.
local_blks_readInt64Temp table blocks read from disk. High values indicate large temp tables exceeding temp_buffers.
local_blks_dirtiedInt64Temp table blocks modified.
local_blks_writtenInt64Temp table blocks written to disk. High values mean temp tables are spilling due to temp_buffers exhaustion.

Temp file usage

Temp files are used when work_mem is insufficient for sorts, hash joins, or materialization. Unlike local buffers, these are always on disk. Non-zero values indicate work_mem pressure.
ColumnTypeDescription
temp_blks_readInt64Temp file blocks read back. High values mean external sorts or hashes are re-reading spilled data.
temp_blks_writtenInt64Temp file blocks written. First place to look when a query is unexpectedly slow. Consider increasing work_mem or optimizing the query to reduce intermediate data volume.

I/O timing

These columns show actual time spent on I/O operations, not just block counts. They separate storage bottlenecks from CPU bottlenecks.
All I/O timing columns are zero unless track_io_timing = on is set in postgresql.conf.
ColumnTypePG versionDescription
shared_blk_read_time_usInt6416+Time spent reading shared blocks (microseconds). Divide by shared_blks_read for average latency per block. Values above 10ms/block may indicate storage issues.
shared_blk_write_time_usInt6416+Time spent writing shared blocks. Usually low unless the backend is forced to write (background writer falling behind).
local_blk_read_time_usInt6417+Time spent reading local (temp table) blocks.
local_blk_write_time_usInt6417+Time spent writing local blocks.
temp_blk_read_time_usInt6416+Time spent reading temp files. High values combined with high temp_blks_read indicate work_mem spills are causing an I/O bottleneck.
temp_blk_write_time_usInt6416+Time spent writing temp files. Often dominates total query time when work_mem is undersized.

WAL usage

Write-Ahead Log metrics show write activity. Useful for replication bandwidth planning and understanding checkpoint behavior.
ColumnTypeDescription
wal_recordsInt64Number of WAL records generated. High values indicate write-intensive queries.
wal_fpiInt64WAL full-page images generated. These spike after each checkpoint then decrease, creating a sawtooth pattern. High FPI counts increase WAL volume significantly.
wal_bytesUInt64Total WAL bytes generated. Sum over time to estimate WAL generation rate for capacity planning. Directly impacts replication lag.

CPU time

User vs system CPU time breakdown. Measured via getrusage().
ColumnTypeDescription
cpu_user_time_usInt64CPU time in user mode (microseconds). High user time with high duration_us means a CPU-bound query. Low user time with high duration_us means an I/O-bound query.
cpu_sys_time_usInt64CPU time in kernel mode (microseconds). Usually low relative to user time. Very high values may indicate lock contention or excessive I/O syscalls.

JIT compilation

JIT (Just-In-Time) compilation can speed up complex queries but has compilation overhead. These fields are zero when JIT is not triggered (query cost below jit_above_cost).
ColumnTypePG versionDescription
jit_functionsInt3216+Number of functions JIT-compiled. Non-zero means JIT was triggered for this query.
jit_generation_time_usInt3216+Time generating JIT IR code. If this is high relative to duration_us, JIT overhead exceeds its benefit for this query. Consider raising jit_above_cost.
jit_deform_time_usInt3217+Time JIT-compiling tuple deform functions. High values indicate queries touching many columns or complex types.
jit_inlining_time_usInt3216+Time inlining functions. Inlining can speed up execution but has compile cost.
jit_optimization_time_usInt3216+Time running LLVM optimization passes.
jit_emission_time_usInt3216+Time emitting final machine code.

Parallel query

Parallel query statistics show how many workers were planned vs actually launched.
ColumnTypePG versionDescription
parallel_workers_plannedInt1618+Workers planned by the query optimizer based on table size and cost settings.
parallel_workers_launchedInt1618+Workers actually launched. If less than planned, the system is hitting max_parallel_workers limits.

Error information

Error fields are populated when a query produces an error or warning (captured via PostgreSQL’s emit_log_hook). For successful queries, err_elevel is 0.
ColumnTypeDescription
err_sqlstateFixedString(5)5-character SQLSTATE error code. See common SQLSTATE codes below.
err_elevelUInt8Error severity: 0 = success, 19 = WARNING, 21 = ERROR, 22 = FATAL, 23 = PANIC. Filter err_elevel >= 21 for actual errors.
err_messageStringHuman-readable error description, truncated to 2 KB.
The minimum captured severity is controlled by pg_stat_ch.log_min_elevel (default: warning).

Common SQLSTATE codes

CodeNameTypical cause
42P01undefined_tableTable does not exist
42703undefined_columnColumn does not exist
23505unique_violationDuplicate key on INSERT/UPDATE
23503foreign_key_violationReferenced row does not exist
42601syntax_errorSQL syntax error
57014query_canceledstatement_timeout or manual cancel
40001serialization_failureSerializable isolation conflict (retry)
53100disk_fullOut of disk space
53200out_of_memoryPostgreSQL out of memory

Error level values

LevelValueCaptured by default
DEBUG5-DEBUG110-14No
LOG15No
INFO17No
NOTICE18No
WARNING19Yes
ERROR21Yes
FATAL22Yes
PANIC23Yes

Client context

ColumnTypeDescription
appLowCardinality(String)Application name from the application_name connection parameter or GUC. Common values: psql, pgAdmin, myapp-api, pg_dump.
client_addrStringClient IP address. Local connections show as 127.0.0.1.