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

Commit16e6c96

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 parent59112f2 commit16e6c96

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
@@ -1874,11 +1874,8 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
18741874
{
18751875
BlockNumberold_rel_pages=vacrelstats->rel_pages;
18761876
BlockNumbernew_rel_pages;
1877-
PGRUsageru0;
18781877
intlock_retry;
18791878

1880-
pg_rusage_init(&ru0);
1881-
18821879
/* Report that we are now truncating */
18831880
pgstat_progress_update_param(PROGRESS_VACUUM_PHASE,
18841881
PROGRESS_VACUUM_PHASE_TRUNCATE);
@@ -1888,6 +1885,10 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
18881885
*/
18891886
do
18901887
{
1888+
PGRUsageru0;
1889+
1890+
pg_rusage_init(&ru0);
1891+
18911892
/*
18921893
* We need full exclusive lock on the relation in order to do
18931894
* truncation. If we can't get it, give up rather than waiting --- we

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp