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

Commit77bb65d

Browse files
committed
Revert based on Tom's recommendation:
> Allow VACUUM to complete faster by avoiding scanning the indexes when no> rows were removed from the heap by the VACUUM.
1 parentbf32494 commit77bb65d

File tree

7 files changed

+29
-65
lines changed

7 files changed

+29
-65
lines changed

‎src/backend/access/gist/gistvacuum.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.12 2006/02/1116:59:08 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.13 2006/02/1117:14:08 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -125,7 +125,7 @@ gistVacuumUpdate(GistVacuum *gv, BlockNumber blkno, bool needunion)
125125
if (chldtuple.ituplen>1)
126126
{
127127
/*
128-
* child wassplit, so we need mark completion
128+
* child wassplitted, so we need mark completion
129129
* insert(split)
130130
*/
131131
intj;
@@ -329,9 +329,9 @@ gistVacuumUpdate(GistVacuum *gv, BlockNumber blkno, bool needunion)
329329
}
330330

331331
/*
332-
* Forusual vacuum just update FSM, for full vacuum
332+
* Forusial vacuum just update FSM, for full vacuum
333333
* reforms parent tuples if some of childs was deleted or changed,
334-
* update invalid tuples (they canexist from last crash recovery only),
334+
* update invalid tuples (they canexsist from last crash recovery only),
335335
* tries to get smaller index
336336
*/
337337

@@ -505,15 +505,10 @@ gistbulkdelete(PG_FUNCTION_ARGS)
505505
*ptr;
506506
boolneedLock;
507507

508-
if (callback_state)
509-
{
510-
stack= (GistBDItem*)palloc0(sizeof(GistBDItem));
508+
stack= (GistBDItem*)palloc0(sizeof(GistBDItem));
511509

512-
stack->blkno=GIST_ROOT_BLKNO;
513-
needFullVacuum= false;
514-
}
515-
else
516-
stack=NULL;
510+
stack->blkno=GIST_ROOT_BLKNO;
511+
needFullVacuum= false;
517512

518513
while (stack)
519514
{

‎src/backend/access/hash/hash.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.84 2006/02/1116:59:09 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.85 2006/02/1117:14:08 momjian Exp $
1212
*
1313
* NOTES
1414
* This file contains only the public interface routines.
@@ -496,17 +496,6 @@ hashbulkdelete(PG_FUNCTION_ARGS)
496496
tuples_removed=0;
497497
num_index_tuples=0;
498498

499-
/* return statistics */
500-
num_pages=RelationGetNumberOfBlocks(rel);
501-
502-
result= (IndexBulkDeleteResult*)palloc0(sizeof(IndexBulkDeleteResult));
503-
result->num_pages=num_pages;
504-
505-
if (!callback_state)
506-
{
507-
PG_RETURN_POINTER(result);
508-
}
509-
510499
/*
511500
* Read the metapage to fetch original bucket and tuple counts. Also, we
512501
* keep a copy of the last-seen metapage so that we can use its
@@ -655,6 +644,11 @@ hashbulkdelete(PG_FUNCTION_ARGS)
655644

656645
_hash_wrtbuf(rel,metabuf);
657646

647+
/* return statistics */
648+
num_pages=RelationGetNumberOfBlocks(rel);
649+
650+
result= (IndexBulkDeleteResult*)palloc0(sizeof(IndexBulkDeleteResult));
651+
result->num_pages=num_pages;
658652
result->num_index_tuples=num_index_tuples;
659653
result->tuples_removed=tuples_removed;
660654

‎src/backend/access/index/indexam.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.88 2006/02/1116:59:09 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.89 2006/02/1117:14:08 momjian Exp $
1212
*
1313
* INTERFACE ROUTINES
1414
*index_open- open an index relation by relation OID
@@ -685,11 +685,6 @@ index_getmulti(IndexScanDesc scan,
685685
*callback routine tells whether a given main-heap tuple is
686686
*to be deleted
687687
*
688-
* passing NULL callback_state can be interpreted by the
689-
* index access method as meaning that the index does not need
690-
* to be scanned in logical sequence to remove rows for this call
691-
* index_vacuum_cleanup is always required after this, however.
692-
*
693688
*return value is an optional palloc'd struct of statistics
694689
* ----------------
695690
*/

‎src/backend/access/nbtree/nbtree.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.137 2006/02/1116:59:09 momjian Exp $
15+
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.138 2006/02/1117:14:08 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -543,9 +543,8 @@ btbulkdelete(PG_FUNCTION_ARGS)
543543
doublenum_index_tuples;
544544
OffsetNumberdeletable[MaxOffsetNumber];
545545
intndeletable;
546-
Bufferbuf=NULL;
546+
Bufferbuf;
547547
BlockNumbernum_pages;
548-
boolscanindex= true;
549548

550549
tuples_removed=0;
551550
num_index_tuples=0;
@@ -566,15 +565,8 @@ btbulkdelete(PG_FUNCTION_ARGS)
566565
* skip obtaining exclusive lock on empty pages though, since no indexscan
567566
* could be stopped on those.
568567
*/
569-
if (callback_state)
570-
{
571-
buf=_bt_get_endpoint(rel,0, false);
572-
scanindex=BufferIsValid(buf);/* check for empty index */
573-
}
574-
else
575-
scanindex= false;
576-
577-
if (scanindex)
568+
buf=_bt_get_endpoint(rel,0, false);
569+
if (BufferIsValid(buf))/* check for empty index */
578570
{
579571
for (;;)
580572
{
@@ -657,10 +649,7 @@ btbulkdelete(PG_FUNCTION_ARGS)
657649

658650
result= (IndexBulkDeleteResult*)palloc0(sizeof(IndexBulkDeleteResult));
659651
result->num_pages=num_pages;
660-
if (scanindex)
661-
result->num_index_tuples=num_index_tuples;
662-
else
663-
result->num_index_tuples=-1;
652+
result->num_index_tuples=num_index_tuples;
664653
result->tuples_removed=tuples_removed;
665654

666655
PG_RETURN_POINTER(result);

‎src/backend/commands/vacuum.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.322 2006/02/1116:59:09 momjian Exp $
16+
* $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.323 2006/02/1117:14:09 momjian Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -719,8 +719,7 @@ vac_update_relstats(Oid relid, BlockNumber num_pages, double num_tuples,
719719
/* overwrite the existing statistics in the tuple */
720720
pgcform= (Form_pg_class)GETSTRUCT(&rtup);
721721
pgcform->relpages= (int32)num_pages;
722-
if (num_tuples >=0 )
723-
pgcform->reltuples= (float4)num_tuples;
722+
pgcform->reltuples= (float4)num_tuples;
724723
pgcform->relhasindex=hasindex;
725724

726725
/*
@@ -2962,18 +2961,15 @@ scan_index(Relation indrel, double num_tuples)
29622961
if (!stats)
29632962
return;
29642963

2965-
/* now update statistics in pg_class
2966-
* we use the number of tuples from the table because we have not
2967-
* actually scanned the index, so don't know the number of tuples in index
2968-
*/
2964+
/* now update statistics in pg_class */
29692965
vac_update_relstats(RelationGetRelid(indrel),
2970-
stats->num_pages,num_tuples,
2966+
stats->num_pages,stats->num_index_tuples,
29712967
false);
29722968

29732969
ereport(elevel,
29742970
(errmsg("index \"%s\" now contains %.0f row versions in %u pages",
29752971
RelationGetRelationName(indrel),
2976-
num_tuples,
2972+
stats->num_index_tuples,
29772973
stats->num_pages),
29782974
errdetail("%u index pages have been deleted, %u are currently reusable.\n"
29792975
"%s.",

‎src/backend/commands/vacuumlazy.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*
3232
*
3333
* IDENTIFICATION
34-
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.64 2006/02/1116:59:09 momjian Exp $
34+
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.65 2006/02/1117:14:09 momjian Exp $
3535
*
3636
*-------------------------------------------------------------------------
3737
*/
@@ -639,19 +639,16 @@ lazy_scan_index(Relation indrel, LVRelStats *vacrelstats)
639639
if (!stats)
640640
return;
641641

642-
/* now update statistics in pg_class
643-
* we use the number of tuples from the table because we have not
644-
* actually scanned the index, so don't know the number of tuples in index
645-
*/
642+
/* now update statistics in pg_class */
646643
vac_update_relstats(RelationGetRelid(indrel),
647644
stats->num_pages,
648-
vacrelstats->rel_tuples,
645+
stats->num_index_tuples,
649646
false);
650647

651648
ereport(elevel,
652649
(errmsg("index \"%s\" now contains %.0f row versions in %u pages",
653650
RelationGetRelationName(indrel),
654-
vacrelstats->rel_tuples,
651+
stats->num_index_tuples,
655652
stats->num_pages),
656653
errdetail("%u index pages have been deleted, %u are currently reusable.\n"
657654
"%s.",

‎src/include/access/genam.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/access/genam.h,v 1.55 2006/02/1116:59:09 momjian Exp $
10+
* $PostgreSQL: pgsql/src/include/access/genam.h,v 1.56 2006/02/1117:14:09 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -38,8 +38,6 @@ typedef struct IndexBulkDeleteResult
3838
BlockNumbernum_pages;/* pages remaining in index */
3939
BlockNumberpages_removed;/* # removed by bulk-delete operation */
4040
doublenum_index_tuples;/* tuples remaining */
41-
/* should set to -1 if index not scanned */
42-
/* because no records to delete */
4341
doubletuples_removed;/* # removed by bulk-delete operation */
4442
BlockNumberpages_deleted;/* # unused pages in index */
4543
BlockNumberpages_free;/* # pages available for reuse */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp