问题
I have an autovacuum process running on pg_toast:
select query, from pg_stat_activity where query like '%autov%';
"autovacuum: VACUUM pg_toast.pg_toast_15404513 "
How do I find out what table/index/whatever this pg_toast pertains to? Or is the autovacuum working on something else?
回答1:
I think you'll want something like:
select n.nspname, c.relname
from pg_class c
inner join pg_namespace n on c.relnamespace = n.oid
where reltoastrelid = (
select oid
from pg_class
where relname = 'pg_toast_15404513'
and relnamespace = (SELECT n2.oid FROM pg_namespace n2 WHERE n2.nspname = 'pg_toast') )
It'd be nice if Pg reported this in the vacuum command summary.
回答2:
Here's a shorter way:
select 15404513::regclass;
where 15404513
is pg_toast_
suffix.
来源:https://stackoverflow.com/questions/18456026/postgres-pg-toast-in-autovacuum-which-table