*wraparound = force_vacuum;
/* User disabled it in pg_class.reloptions? (But ignore if at risk) */
- if (!force_vacuum && !av_enabled)
+ if (!av_enabled && !force_vacuum)
{
*doanalyze = false;
*dovacuum = false;
return;
}
- if (PointerIsValid(tabentry))
+ /*
+ * If we found the table in the stats hash, and autovacuum is currently
+ * enabled, make a threshold-based decision whether to vacuum and/or
+ * analyze. If autovacuum is currently disabled, we must be here for
+ * anti-wraparound vacuuming only, so don't vacuum (or analyze) anything
+ * that's not being forced.
+ */
+ if (PointerIsValid(tabentry) && AutoVacuumingActive())
{
reltuples = classForm->reltuples;
vactuples = tabentry->n_dead_tuples;