Vacuum & pg_class.relallvisible

From: Rob Emery <re-pgsql(at)codeweavers(dot)net>
To: pgsql-admin(at)postgresql(dot)org
Subject: Vacuum & pg_class.relallvisible
Date: 2019-10-17 16:32:23
Message-ID: CAPCETpuY2ooOjzhWzSAaQq_gCO8oK-W3emBZr3yA_5EdGYEUtA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hiya,

I've been attempting to figure out if the autovacuum/vacuum process will use
pgclass.relallvisible when vacuuming a table to know if it's able to
skip freezing at all.

Basically we have tables that this query:
```
SELECT c.oid::regclass as table_name,
greatest(age(c.relfrozenxid),age(t.relfrozenxid)) as age
FROM pg_class c
LEFT JOIN pg_class t ON c.reltoastrelid = t.oid
WHERE c.relkind IN ('r', 'm')
ORDER BY age DESC
```

returns the age as greater than 'autovacuum_freeze_max_age' which was making
us believe that autovacuum wasn't running.

When we looked into the actual rows with:

```
SELECT t_infomask::bit(16) as bits, t_infomask::bit(16) & (x'0100' |
x'0200') as isFrozen FROM heap_page_items(get_raw_page('tablename',
0))
```
we could see that it looks like all the rows in the table are frozen;
so it would never need a vacuum!

I don't understand how the autovacuum knows that it can skip that
table without looking at all the rows, which is the process of
vacuuming that table!

Much appreciated if someone can clean up my understanding.

Thanks,
--
Rob

<> Codeweavers

--

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Laurenz Albe 2019-10-17 16:41:12 Re: Vacuum & pg_class.relallvisible
Previous Message Pepe TD Vo 2019-10-17 13:28:49 Re: can't call function to delete the table