max freeze age query in docs - Mailing list pgsql-hackers

From Andrew Dunstan
Subject max freeze age query in docs
Date
Msg-id 5223DD00.4060002@dunslane.net
Whole thread Raw
List pgsql-hackers
The other day I followed the docs and ran this query:
   SELECT relname, age(relfrozenxid) FROM pg_class WHERE relkind = 'r';


Then after identifying some tables that were close to triggering an 
automatic vacuum, we vacuumed them only to find that the age of the 
database's datfrozenxid hadn't gone down much. A little digging revealed 
that some TOAST tables had some quite old xids hanging around. so I 
think we need to change the query, maybe to something like:
   select c.relname, int4larger(age(c.relfrozenxid),                              case when c.reltoastrelid = 0 then 0
else  age(t.relfrozenxid) end) as age   from pg_class c       left join pg_class t on c.reltoastrelid = t.oid   where
c.relkind= 'r'
 

Maybe for bonus points we'd print out the schema (e.g. by selectting 
c.oid::regclass instead of c.relname), and also include materialized 
views which are omitted from the query altogether.

Comments?

cheers

andrew




pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: [v9.4] row level security
Next
From: Josh Berkus
Date:
Subject: Re: max freeze age query in docs