You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've run across a pretty serious problem with pg_autovacuum.
pg_autovacuum looses track of any table that's ever been truncated
(possibly other situations too). When i truncate a table it gets a
new relfilenode in pg_class. This is a problem because pg_autovacuum
assumes pg_class.relfilenode will join to pg_stats_all_tables.relid.
pg_stats_all_tables.relid is actallly the oid from pg_class, not the
relfilenode. These two values start out equal so pg_autovacuum works
initially, but it fails later on because of this incorrect assumption.
This patch fixes that problem. Applied to HEAD and 7.4.X.
Brian Hirt
Copy file name to clipboardExpand all lines: contrib/pg_autovacuum/pg_autovacuum.h
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -34,10 +34,10 @@
34
34
#defineVACUUM_ANALYZE 0
35
35
#defineANALYZE_ONLY 1
36
36
37
-
#defineTABLE_STATS_QUERY "select a.relfilenode,a.relname,a.relnamespace,a.relpages,a.relisshared,a.reltuples,b.schemaname,b.n_tup_ins,b.n_tup_upd,b.n_tup_del from pg_class a, pg_stat_all_tables b where a.relfilenode=b.relid and a.relkind = 'r'"
37
+
#defineTABLE_STATS_QUERY "select a.oid,a.relname,a.relnamespace,a.relpages,a.relisshared,a.reltuples,b.schemaname,b.n_tup_ins,b.n_tup_upd,b.n_tup_del from pg_class a, pg_stat_all_tables b where a.oid=b.relid and a.relkind = 'r'"
38
38
39
39
#defineFRONTEND
40
-
#definePAGES_QUERY "select relfilenode,reltuples,relpages from pg_class where relfilenode=%i"
40
+
#definePAGES_QUERY "select oid,reltuples,relpages from pg_class where oid=%i"
41
41
#defineFROZENOID_QUERY "select oid,age(datfrozenxid) from pg_database where datname = 'template1'"
42
42
#defineFROZENOID_QUERY2 "select oid,datname,age(datfrozenxid) from pg_database where datname!='template0'"
0 commit comments