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 :

ColumnTypeDescription
relidintThis column represents the table ID
relnametextThis column represents the table name
schemanametextThis column represents the schema name that this table is in
heap_blks_readintunused
heap_blks_hitintunused
idx_blks_readintunused
idx_blks_hitintunused
toast_blks_readintunused
toast_blks_hitintunused
tidx_blks_readintunused
tidx_blks_hitintunused

Example

  1. Create a new table.
CREATE TABLE example_table (
    data text,
    cluster text,
    storage int
);
  1. 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;
  1. It will return the table size in bytes.
 relid | schemaname |  relname    
-------+------------+---------------
 16384 | public     | job          
 16385 | public     | example_table
(2 rows)