Re: auto-vacuum & Negative "anl" Values

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Dylan Hansen <dhansen(at)pixpo(dot)com>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: auto-vacuum & Negative "anl" Values
Date: 2006-06-27 03:49:00
Message-ID: 20060627034900.GD467@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dylan Hansen wrote:
> So can I assume that this is a bug?

Definitively a bug.

> The only resolution I can see right now is to setup a cron job that
> will perform an ANALYZE periodically, as the pg_autovacuum ANALYZE
> threshold is never reached.
>
> Any other suggestions? Thanks for the input!

I just committed a fix, so the other alternative is get a CVS checkout
from the 8.1 branch and put it up to see if it fixes your problem. The
relevant patch is below.

Index: src/backend/postmaster/pgstat.c
===================================================================
RCS file: /home/alvherre/cvs/pgsql/src/backend/postmaster/pgstat.c,v
retrieving revision 1.111.2.3
diff -c -p -r1.111.2.3 pgstat.c
*** src/backend/postmaster/pgstat.c 19 May 2006 15:15:38 -0000 1.111.2.3
--- src/backend/postmaster/pgstat.c 27 Jun 2006 03:36:03 -0000
*************** pgstat_recv_vacuum(PgStat_MsgVacuum *msg
*** 2919,2924 ****
--- 2919,2930 ----
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);
+ }
}

/* ----------
*************** pgstat_recv_tabstat(PgStat_MsgTabstat *m
*** 3055,3061 ****
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_dead_tuples += tabmsg[i].t_tuples_updated +
tabmsg[i].t_tuples_deleted;

--- 3061,3068 ----
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 -
! tabmsg[i].t_tuples_deleted;
tabentry->n_dead_tuples += tabmsg[i].t_tuples_updated +
tabmsg[i].t_tuples_deleted;

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Almeida do Lago 2006-06-27 03:52:48 FKs Lock Contention
Previous Message arie nugraha 2006-06-27 03:07:11 Re: inheritance and table