pg_stat_kcache
pg_stat_kcache
pg_stat_kcache : Kernel statistics gathering
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 6220 | pg_stat_kcache
|
pg_stat_kcache
|
2.3.1 |
STAT
|
BSD 3-Clause
|
C
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--sLd-r
|
No
|
Yes
|
Yes
|
Yes
|
yes
|
no
|
| Relationships | |
|---|---|
| Requires | pg_stat_statements
|
| See Also | pg_profile
powa
plprofiler
pg_stat_monitor
pg_qualstats
pg_track_settings
pg_wait_sampling
system_stats
|
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PGDG
|
2.3.1 |
18
17
16
15
14
|
pg_stat_kcache |
pg_stat_statements |
| RPM | PGDG
|
2.3.1 |
18
17
16
15
14
|
pg_stat_kcache_$v |
- |
| DEB | PGDG
|
2.3.1 |
18
17
16
15
14
|
postgresql-$v-pg-stat-kcache |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
el8.aarch64
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
el9.x86_64
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
el9.aarch64
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
el10.x86_64
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
el10.aarch64
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
d12.x86_64
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
d12.aarch64
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
d13.x86_64
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
d13.aarch64
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
u22.x86_64
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
u22.aarch64
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
u24.x86_64
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
u24.aarch64
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
PGDG 2.3.1
|
Source
Install
Make sure PGDG repo available:
pig repo add pgdg -u # add pgdg repo and update cacheInstall this extension with pig:
pig install pg_stat_kcache; # install via package name, for the active PG version
pig install pg_stat_kcache -v 18; # install for PG 18
pig install pg_stat_kcache -v 17; # install for PG 17
pig install pg_stat_kcache -v 16; # install for PG 16
pig install pg_stat_kcache -v 15; # install for PG 15
pig install pg_stat_kcache -v 14; # install for PG 14Config this extension to shared_preload_libraries:
shared_preload_libraries = 'pg_stat_statements, pg_stat_kcache';Create this extension with:
CREATE EXTENSION pg_stat_kcache CASCADE; -- requires pg_stat_statementsUsage
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;Last updated on