Home > Back-end >  visibility map: all visible pages
visibility map: all visible pages

Time:11-03

The relallvisible field in pg_class view display the Number of pages that are marked all-visible in the table's visibility map.

When I try this example:

INSERT INTO foo (x) SELECT n FROM generate_series(1, 10000000) as n;  

analyze table foo;

select nspname, relpages, reltuples, relallvisible, relfrozenxid, relminmxidfrom pg_class as c
join pg_namespace as ns on c.relnamespace = ns.oid
where relname = 'foo';
 nspname | relpages |  reltuples  | relallvisible | relfrozenxid | relminmxid
--------- ---------- ------------- --------------- -------------- ------------
 public  |    44248 | 9.99998e 06 |             0 |        60995 |          1
(1 row)

Why is relallvisible field equal to 0 and not equal to the total number of pages that is 44248?

CodePudding user response:

Because VACUUM has never run on the table. That command builds and maintains the visibility map.

You are probably on PostgreSQL v12 or lower, and the table not received enough updates or deletes to trigger autovacuum. If your use case involves insert-only tables, upgrade – from v13 on, autovacuum will also run on insert-only tables.

  • Related