|
13 | 13 | * |
14 | 14 | * Copyright (c) 2001-2007, PostgreSQL Global Development Group |
15 | 15 | * |
16 | | - * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.157 2007/05/27 05:37:49 tgl Exp $ |
| 16 | + * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.158 2007/05/27 17:28:35 tgl Exp $ |
17 | 17 | * ---------- |
18 | 18 | */ |
19 | 19 | #include "postgres.h" |
@@ -1376,7 +1376,8 @@ AtEOXact_PgStat(bool isCommit) |
1376 | 1376 | Assert(tabstat->trans == trans); |
1377 | 1377 | if (isCommit) |
1378 | 1378 | { |
1379 | | - tabstat->t_counts.t_new_live_tuples += trans->tuples_inserted; |
| 1379 | + tabstat->t_counts.t_new_live_tuples += |
| 1380 | + trans->tuples_inserted - trans->tuples_deleted; |
1380 | 1381 | tabstat->t_counts.t_new_dead_tuples += trans->tuples_deleted; |
1381 | 1382 | } |
1382 | 1383 | else |
@@ -1563,7 +1564,8 @@ pgstat_twophase_postcommit(TransactionId xid, uint16 info, |
1563 | 1564 | /* Find or create a tabstat entry for the rel */ |
1564 | 1565 | pgstat_info = get_tabstat_entry(rec->t_id, rec->t_shared); |
1565 | 1566 |
|
1566 | | - pgstat_info->t_counts.t_new_live_tuples += rec->tuples_inserted; |
| 1567 | + pgstat_info->t_counts.t_new_live_tuples += |
| 1568 | + rec->tuples_inserted - rec->tuples_deleted; |
1567 | 1569 | pgstat_info->t_counts.t_new_dead_tuples += rec->tuples_deleted; |
1568 | 1570 | } |
1569 | 1571 |
|
@@ -2919,6 +2921,9 @@ pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len) |
2919 | 2921 | tabentry->blocks_hit += tabmsg[i].t_counts.t_blocks_hit; |
2920 | 2922 | } |
2921 | 2923 |
|
| 2924 | + /* Clamp n_live_tuples in case of negative new_live_tuples */ |
| 2925 | + tabentry->n_live_tuples = Max(tabentry->n_live_tuples, 0); |
| 2926 | + |
2922 | 2927 | /* |
2923 | 2928 | * Add per-table stats to the per-database entry, too. |
2924 | 2929 | */ |
@@ -3113,7 +3118,7 @@ pgstat_recv_vacuum(PgStat_MsgVacuum *msg, int len) |
3113 | 3118 | } |
3114 | 3119 | else |
3115 | 3120 | { |
3116 | | - /* last_anl_tuples must never exceed n_live_tuples */ |
| 3121 | + /* last_anl_tuples must never exceed n_live_tuples+n_dead_tuples */ |
3117 | 3122 | tabentry->last_anl_tuples = Min(tabentry->last_anl_tuples, |
3118 | 3123 | msg->m_tuples); |
3119 | 3124 | } |
|
0 commit comments