pg_class returns 0 as relpages



  • I have this table:

                      Table "public.region"
       Column    |   Type   | Collation | Nullable | Default 
    -------------+----------+-----------+----------+---------
     r_regionkey | smallint |           | not null | 
     r_name      | text     |           |          | 
     r_comment   | text     |           |          | 
    Indexes:
        "region_pkey" PRIMARY KEY, btree (r_regionkey)
    Referenced by:
        TABLE "nation" CONSTRAINT "nation_n_regionkey_fkey" FOREIGN KEY (n_regionkey) REFERENCES region(r_regionkey)
    

    weirdly this query:

    select oid::regclass as tbl, relpages
    from pg_class
    where relname='region'
    

    returns relpages = 0.

    • Why and how can I fix? If I change smallint to int it works (relpages = 1)


  • Your table is so small that autoanalyze never got triggered. Since autovacuum_analyze_threshold is 50 by default, tables with less than 50 data modifications are not automatically analyzed.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2