Skip to content

Commit 32ad0fc

Browse files
committed
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.
1 parent dc2c25f commit 32ad0fc

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/backend/postmaster/pgstat.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* Copyright (c) 2001-2006, PostgreSQL Global Development Group
1515
*
16-
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.130 2006/06/20 22:52:00 tgl Exp $
16+
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.131 2006/06/27 03:45:16 alvherre Exp $
1717
* ----------
1818
*/
1919
#include "postgres.h"
@@ -2635,7 +2635,8 @@ pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len)
26352635
tabentry->tuples_updated += tabmsg[i].t_tuples_updated;
26362636
tabentry->tuples_deleted += tabmsg[i].t_tuples_deleted;
26372637

2638-
tabentry->n_live_tuples += tabmsg[i].t_tuples_inserted;
2638+
tabentry->n_live_tuples += tabmsg[i].t_tuples_inserted -
2639+
tabmsg[i].t_tuples_deleted;
26392640
tabentry->n_dead_tuples += tabmsg[i].t_tuples_updated +
26402641
tabmsg[i].t_tuples_deleted;
26412642

@@ -2830,6 +2831,12 @@ pgstat_recv_vacuum(PgStat_MsgVacuum *msg, int len)
28302831
else
28312832
tabentry->analyze_timestamp = msg->m_vacuumtime;
28322833
}
2834+
else
2835+
{
2836+
/* last_anl_tuples must never exceed n_live_tuples */
2837+
tabentry->last_anl_tuples = Min(tabentry->last_anl_tuples,
2838+
msg->m_tuples);
2839+
}
28332840
}
28342841

28352842
/* ----------

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy