pg_stat_kcache
Kernel statistics gathering
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_stat_kcache | 2.3.1 | STAT | BSD 3-Clause | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 6220 | pg_stat_kcache | No | Yes | Yes | Yes | No | Yes | - |
| Related | pg_stat_statements pg_profile powa plprofiler pg_stat_monitor pg_qualstats pg_track_settings pg_wait_sampling system_stats |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PGDG | 2.3.1 | 1817161514 | pg_stat_kcache | pg_stat_statements |
| RPM | PGDG | 2.3.1 | 1817161514 | pg_stat_kcache_$v | - |
| DEB | PGDG | 2.3.1 | 1817161514 | postgresql-$v-pg-stat-kcache | - |
Install
You can install pg_stat_kcache directly. First, make sure the PGDG repository is added and enabled:
pig repo add pgdg -u # Add PGDG repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install pg_stat_kcache; # Install for current active PG version
pig ext install -y pg_stat_kcache -v 18 # PG 18
pig ext install -y pg_stat_kcache -v 17 # PG 17
pig ext install -y pg_stat_kcache -v 16 # PG 16
pig ext install -y pg_stat_kcache -v 15 # PG 15
pig ext install -y pg_stat_kcache -v 14 # PG 14
dnf install -y pg_stat_kcache_18 # PG 18
dnf install -y pg_stat_kcache_17 # PG 17
dnf install -y pg_stat_kcache_16 # PG 16
dnf install -y pg_stat_kcache_15 # PG 15
dnf install -y pg_stat_kcache_14 # PG 14
apt install -y postgresql-18-pg-stat-kcache # PG 18
apt install -y postgresql-17-pg-stat-kcache # PG 17
apt install -y postgresql-16-pg-stat-kcache # PG 16
apt install -y postgresql-15-pg-stat-kcache # PG 15
apt install -y postgresql-14-pg-stat-kcache # PG 14
Preload:
shared_preload_libraries = 'pg_stat_statements, pg_stat_kcache';
Create Extension:
CREATE EXTENSION pg_stat_kcache CASCADE; -- requires: pg_stat_statements
Usage
pg_stat_kcache gathers statistics about real reads and writes done by the filesystem layer, as well as CPU usage per query. It requires pg_stat_statements.
Views
pg_stat_kcache – aggregated per-database statistics:
| Column | Type | Description |
|---|---|---|
datname | name | Database name |
exec_user_time | double precision | User CPU time executing statements (seconds) |
exec_system_time | double precision | System CPU time executing statements (seconds) |
exec_reads | bigint | Bytes read by filesystem layer |
exec_reads_blks | bigint | 8K blocks read by filesystem layer |
exec_writes | bigint | Bytes written by filesystem layer |
exec_writes_blks | bigint | 8K blocks written by filesystem layer |
plan_user_time | double precision | User CPU time planning (if tracking enabled) |
plan_system_time | double precision | System CPU time planning (if tracking enabled) |
pg_stat_kcache_detail – per-query statistics including query text, role, and database.
Functions
-- Reset all collected statistics
SELECT pg_stat_kcache_reset();
Configuration
| Parameter | Default | Description |
|---|---|---|
pg_stat_kcache.linux_hz | -1 | Linux CONFIG_HZ (auto-detected) |
pg_stat_kcache.track | top | Track: top, all, or none |
pg_stat_kcache.track_planning | off | Track planning statistics (PG 13+) |
Example
SELECT datname, exec_user_time, exec_system_time, exec_reads, exec_writes
FROM pg_stat_kcache;
SELECT query, exec_user_time, exec_system_time, exec_reads
FROM pg_stat_kcache_detail
ORDER BY exec_user_time DESC
LIMIT 10;
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.