statio_user_tables collector exposes I/O statistics for user tables, tracking buffer cache performance for heap, index, and TOAST data.
Status
Default: EnabledMetrics
Heap I/O Metrics
pg_statio_user_tables_heap_blocks_read
Type: CounterDescription: Number of disk blocks read from this table’s heap Labels:
datname, schemaname, relname
pg_statio_user_tables_heap_blocks_hit
Type: CounterDescription: Number of buffer hits in this table’s heap Labels:
datname, schemaname, relname
Index I/O Metrics
pg_statio_user_tables_idx_blocks_read
Type: CounterDescription: Number of disk blocks read from all indexes on this table Labels:
datname, schemaname, relname
pg_statio_user_tables_idx_blocks_hit
Type: CounterDescription: Number of buffer hits in all indexes on this table Labels:
datname, schemaname, relname
TOAST I/O Metrics
pg_statio_user_tables_toast_blocks_read
Type: CounterDescription: Number of disk blocks read from this table’s TOAST table (if any) Labels:
datname, schemaname, relname
pg_statio_user_tables_toast_blocks_hit
Type: CounterDescription: Number of buffer hits in this table’s TOAST table (if any) Labels:
datname, schemaname, relname
TOAST Index I/O Metrics
pg_statio_user_tables_tidx_blocks_read
Type: CounterDescription: Number of disk blocks read from this table’s TOAST table indexes (if any) Labels:
datname, schemaname, relname
pg_statio_user_tables_tidx_blocks_hit
Type: CounterDescription: Number of buffer hits in this table’s TOAST table indexes (if any) Labels:
datname, schemaname, relname
SQL Query
PostgreSQL Versions
Supported: All versionsRequired Permissions
The monitoring user needs:- Access to
pg_statio_user_tablesview (granted toPUBLICby default)
Example Output
Use Cases
Table Cache Hit Ratio
Index vs Heap I/O
TOAST Table Activity
Disk-Intensive Tables
Performance Tuning
Low Cache Hit Ratio (< 90%)
If a table has low cache hit ratio:-
Increase shared_buffers:
-
Check table size vs cache:
-
Optimize queries:
- Reduce sequential scans with indexes
- Use index-only scans where possible
- Partition large tables
High TOAST I/O
If TOAST blocks are frequently accessed:- Consider
TOASTstorage strategy: - Compress large columns
- Move large columns to separate tables
Combined I/O Metrics
Alert Examples
Understanding TOAST
TOAST (The Oversized-Attribute Storage Technique) stores large column values out-of-line:- Automatically used for columns > ~2KB
- Has its own table and indexes
- Can impact performance if frequently accessed
- Monitor with
toast_blocks_*metrics