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

Commit0074919

Browse files
committed
Fix mesurement of elapsed time during truncating heap in VACUUM.
VACUUM may truncate heap in several batches. The activity reportis logged for each batch, and contains the number of pages in the tablebefore and after the truncation, and also the elapsed time duringthe truncation. Previously the elapsed time reported in each batch wasthe total elapsed time since starting the truncation until finishingeach batch. For example, if the truncation was processed dividing intothree batches, the second batch reported the accumulated time elapsedduring both first and second batches. This is strange and confusingbecause the number of pages in the table reported together is nottotal. Instead, each batch should report the time elapsed duringonly that batch.The cause of this issue was that the resource usage snapshot wasinitialized only at the beginning of the truncation and was neverreset later. This commit fixes the issue by changing VACUUM so thatthe resource usage snapshot is reset at each batch.Back-patch to all supported branches.Reported-by: Tatsuhito KasaharaAuthor: Tatsuhito KasaharaReviewed-by: Masahiko Sawada, Fujii MasaoDiscussion:https://postgr.es/m/CAP0=ZVJsf=NvQuy+QXQZ7B=ZVLoDV_JzsVC1FRsF1G18i3zMGg@mail.gmail.com
1 parente2e0219 commit0074919

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

‎src/backend/access/heap/vacuumlazy.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,11 +2439,8 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
24392439
{
24402440
BlockNumberold_rel_pages=vacrelstats->rel_pages;
24412441
BlockNumbernew_rel_pages;
2442-
PGRUsageru0;
24432442
intlock_retry;
24442443

2445-
pg_rusage_init(&ru0);
2446-
24472444
/* Report that we are now truncating */
24482445
pgstat_progress_update_param(PROGRESS_VACUUM_PHASE,
24492446
PROGRESS_VACUUM_PHASE_TRUNCATE);
@@ -2453,6 +2450,10 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
24532450
*/
24542451
do
24552452
{
2453+
PGRUsageru0;
2454+
2455+
pg_rusage_init(&ru0);
2456+
24562457
/*
24572458
* We need full exclusive lock on the relation in order to do
24582459
* truncation. If we can't get it, give up rather than waiting --- we

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp