Cloud

pg_statio_user_tables

The pg_statio_user_tables contains one row for each user table in the current database, showing statistics columns filled with zeros.

Columns

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

Examples

  1. Create a new table:

    CREATE TABLE example_table (
        data text,
        cluster text,
        storage int
    );
  2. 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;
  3. This returns the table size in bytes:

     relid | schemaname |  relname
    -------+------------+---------------
     16384 | public     | job
     16385 | public     | example_table
    (2 rows)