System Catalogs
pg_statio_user_tables
Overview
The pg_statio_user_tables
contains one row for each user table in the current database, showing statistics columns filled with zeros.
Columns
This table is designed for compatibility with tools that require PostgreSQL system tables, so it mostly has dummy data. Please note that not all columns in
pg_statio_user_tables
are applicable to every type of relation.The following columns are available for querying in pg_statio_user_tables
:
Column | Type | Description |
---|---|---|
relid | int | This column represents the table ID |
relname | text | This column represents the table name |
schemaname | text | This column represents the schema name that this table is in |
heap_blks_read | int | unused |
heap_blks_hit | int | unused |
idx_blks_read | int | unused |
idx_blks_hit | int | unused |
toast_blks_read | int | unused |
toast_blks_hit | int | unused |
tidx_blks_read | int | unused |
tidx_blks_hit | int | unused |
Example
- Create a new table.
CREATE TABLE example_table (
data text,
cluster text,
storage int
);
- Run the query combined with a
WHERE
clause to look up based on the table name (relname
).
SELECT relid, schemaname, relname FROM pg_statio_user_tables;
- It will return the table size in bytes.
relid | schemaname | relname
-------+------------+---------------
16384 | public | job
16385 | public | example_table
(2 rows)