Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit97d12b4

Browse files
committed
Ooops, I was too busy worrying about getting the transactional infrastructure
right to think carefully about how insert and delete counts map ton_live_tuples. Of course a deletion should reduce n_live_tuples.
1 parenta0c366d commit97d12b4

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

‎src/backend/postmaster/pgstat.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*Copyright (c) 2001-2007, PostgreSQL Global Development Group
1515
*
16-
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.157 2007/05/2705:37:49 tgl Exp $
16+
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.158 2007/05/2717:28:35 tgl Exp $
1717
* ----------
1818
*/
1919
#include"postgres.h"
@@ -1376,7 +1376,8 @@ AtEOXact_PgStat(bool isCommit)
13761376
Assert(tabstat->trans==trans);
13771377
if (isCommit)
13781378
{
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;
13801381
tabstat->t_counts.t_new_dead_tuples+=trans->tuples_deleted;
13811382
}
13821383
else
@@ -1563,7 +1564,8 @@ pgstat_twophase_postcommit(TransactionId xid, uint16 info,
15631564
/* Find or create a tabstat entry for the rel */
15641565
pgstat_info=get_tabstat_entry(rec->t_id,rec->t_shared);
15651566

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;
15671569
pgstat_info->t_counts.t_new_dead_tuples+=rec->tuples_deleted;
15681570
}
15691571

@@ -2919,6 +2921,9 @@ pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len)
29192921
tabentry->blocks_hit+=tabmsg[i].t_counts.t_blocks_hit;
29202922
}
29212923

2924+
/* Clamp n_live_tuples in case of negative new_live_tuples */
2925+
tabentry->n_live_tuples=Max(tabentry->n_live_tuples,0);
2926+
29222927
/*
29232928
* Add per-table stats to the per-database entry, too.
29242929
*/
@@ -3113,7 +3118,7 @@ pgstat_recv_vacuum(PgStat_MsgVacuum *msg, int len)
31133118
}
31143119
else
31153120
{
3116-
/* last_anl_tuples must never exceed n_live_tuples */
3121+
/* last_anl_tuples must never exceed n_live_tuples+n_dead_tuples */
31173122
tabentry->last_anl_tuples=Min(tabentry->last_anl_tuples,
31183123
msg->m_tuples);
31193124
}

‎src/include/pgstat.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
*Copyright (c) 2001-2007, PostgreSQL Global Development Group
77
*
8-
*$PostgreSQL: pgsql/src/include/pgstat.h,v 1.60 2007/05/2705:37:50 tgl Exp $
8+
*$PostgreSQL: pgsql/src/include/pgstat.h,v 1.61 2007/05/2717:28:36 tgl Exp $
99
* ----------
1010
*/
1111
#ifndefPGSTAT_H
@@ -58,6 +58,7 @@ typedef int64 PgStat_Counter;
5858
* tuples_inserted/tuples_updated/tuples_deleted count attempted actions,
5959
* regardless of whether the transaction committed. new_live_tuples and
6060
* new_dead_tuples are properly adjusted depending on commit or abort.
61+
* Note that new_live_tuples can be negative!
6162
* ----------
6263
*/
6364
typedefstructPgStat_TableCounts

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp