0

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)
3
  • So how many rows does the table contain? Does it change if you run vacuum analyze region;? May 13 at 15:26
  • @a_horse_with_no_name yes it changes
    – tail
    May 13 at 15:33
  • Well, that's the answer: that estimate is only updated when the table is analyzed May 13 at 15:34

1 Answer 1

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.