From: Alvaro Herrera Date: Tue, 27 Jun 2006 03:45:28 +0000 (+0000) Subject: Clamp last_anl_tuples to n_live_tuples, in case we vacuum a table without X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=fbc735787728dc7f8ef541eb00bea8da806973c0;p=users%2Fbernd%2Fpostgres.git Clamp last_anl_tuples to n_live_tuples, in case we vacuum a table without analyzing, so that future analyze threshold calculations don't get confused. Also, make sure we correctly track the decrease of live tuples cause by deletes. Per report from Dylan Hansen, patches by Tom Lane and me. --- diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index 8fc6dd2573..d8a00208a2 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -2919,6 +2919,12 @@ pgstat_recv_vacuum(PgStat_MsgVacuum *msg, int len) tabentry->n_dead_tuples = 0; if (msg->m_analyze) tabentry->last_anl_tuples = msg->m_tuples; + else + { + /* last_anl_tuples must never exceed n_live_tuples */ + tabentry->last_anl_tuplse = Min(tabentry->last_anl_tuples, + msg->m_tuples); + } } /* ---------- @@ -3055,7 +3061,8 @@ pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len) tabentry->tuples_updated += tabmsg[i].t_tuples_updated; tabentry->tuples_deleted += tabmsg[i].t_tuples_deleted; - tabentry->n_live_tuples += tabmsg[i].t_tuples_inserted; + tabentry->n_live_tuples += tabmsg[i].t_tuples_inserted - + tabmsg[i].t_tuples_deleted; tabentry->n_dead_tuples += tabmsg[i].t_tuples_updated + tabmsg[i].t_tuples_deleted;