Skip to content

Commit 7537f52

Browse files
committed
Utilize the visibility map in autovacuum, too. There was an oversight in
the visibility map patch that because autovacuum always sets VacuumStmt->freeze_min_age, visibility map was never used for autovacuum, only for manually launched vacuums. This patch introduces a new scan_all field to VacuumStmt, indicating explicitly whether the visibility map should be used, or the whole relation should be scanned, to advance relfrozenxid. Anti-wraparound vacuums still need to scan all pages.
1 parent 69b3383 commit 7537f52

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

src/backend/commands/vacuumlazy.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*
3030
*
3131
* IDENTIFICATION
32-
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.112 2008/12/03 13:05:22 heikki Exp $
32+
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.113 2008/12/04 11:42:23 heikki Exp $
3333
*
3434
*-------------------------------------------------------------------------
3535
*/
@@ -143,7 +143,6 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt,
143143
BlockNumber possibly_freeable;
144144
PGRUsage ru0;
145145
TimestampTz starttime = 0;
146-
bool scan_all;
147146

148147
pg_rusage_init(&ru0);
149148

@@ -169,15 +168,9 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt,
169168
/* Open all indexes of the relation */
170169
vac_open_indexes(onerel, RowExclusiveLock, &nindexes, &Irel);
171170
vacrelstats->hasindex = (nindexes > 0);
172-
173-
/* Should we use the visibility map or scan all pages? */
174-
if (vacstmt->freeze_min_age != -1)
175-
scan_all = true;
176-
else
177-
scan_all = false;
178171

179172
/* Do the vacuuming */
180-
lazy_scan_heap(onerel, vacrelstats, Irel, nindexes, scan_all);
173+
lazy_scan_heap(onerel, vacrelstats, Irel, nindexes, vacstmt->scan_all);
181174

182175
/* Done with indexes */
183176
vac_close_indexes(nindexes, Irel, NoLock);

src/backend/nodes/copyfuncs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Portions Copyright (c) 1994, Regents of the University of California
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.413 2008/11/24 08:46:03 petere Exp $
18+
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.414 2008/12/04 11:42:23 heikki Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -2771,6 +2771,7 @@ _copyVacuumStmt(VacuumStmt *from)
27712771
COPY_SCALAR_FIELD(analyze);
27722772
COPY_SCALAR_FIELD(verbose);
27732773
COPY_SCALAR_FIELD(freeze_min_age);
2774+
COPY_SCALAR_FIELD(scan_all);
27742775
COPY_NODE_FIELD(relation);
27752776
COPY_NODE_FIELD(va_cols);
27762777

src/backend/nodes/equalfuncs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* Portions Copyright (c) 1994, Regents of the University of California
2323
*
2424
* IDENTIFICATION
25-
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.338 2008/11/24 08:46:03 petere Exp $
25+
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.339 2008/12/04 11:42:24 heikki Exp $
2626
*
2727
*-------------------------------------------------------------------------
2828
*/
@@ -1436,6 +1436,7 @@ _equalVacuumStmt(VacuumStmt *a, VacuumStmt *b)
14361436
COMPARE_SCALAR_FIELD(analyze);
14371437
COMPARE_SCALAR_FIELD(verbose);
14381438
COMPARE_SCALAR_FIELD(freeze_min_age);
1439+
COMPARE_SCALAR_FIELD(scan_all);
14391440
COMPARE_NODE_FIELD(relation);
14401441
COMPARE_NODE_FIELD(va_cols);
14411442

src/backend/parser/gram.y

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.641 2008/11/26 08:45:11 petere Exp $
14+
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.642 2008/12/04 11:42:24 heikki Exp $
1515
*
1616
* HISTORY
1717
* AUTHOR DATE MAJOR EVENT
@@ -5837,6 +5837,7 @@ VacuumStmt: VACUUM opt_full opt_freeze opt_verbose
58375837
n->analyze = false;
58385838
n->full = $2;
58395839
n->freeze_min_age = $3 ? 0 : -1;
5840+
n->scan_all = $3;
58405841
n->verbose = $4;
58415842
n->relation = NULL;
58425843
n->va_cols = NIL;
@@ -5849,6 +5850,7 @@ VacuumStmt: VACUUM opt_full opt_freeze opt_verbose
58495850
n->analyze = false;
58505851
n->full = $2;
58515852
n->freeze_min_age = $3 ? 0 : -1;
5853+
n->scan_all = $3;
58525854
n->verbose = $4;
58535855
n->relation = $5;
58545856
n->va_cols = NIL;
@@ -5860,6 +5862,7 @@ VacuumStmt: VACUUM opt_full opt_freeze opt_verbose
58605862
n->vacuum = true;
58615863
n->full = $2;
58625864
n->freeze_min_age = $3 ? 0 : -1;
5865+
n->scan_all = $3;
58635866
n->verbose |= $4;
58645867
$$ = (Node *)n;
58655868
}

src/backend/postmaster/autovacuum.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
*
5656
*
5757
* IDENTIFICATION
58-
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.87 2008/11/12 10:10:32 heikki Exp $
58+
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.88 2008/12/04 11:42:24 heikki Exp $
5959
*
6060
*-------------------------------------------------------------------------
6161
*/
@@ -2649,6 +2649,7 @@ autovacuum_do_vac_analyze(autovac_table *tab,
26492649
vacstmt.full = false;
26502650
vacstmt.analyze = tab->at_doanalyze;
26512651
vacstmt.freeze_min_age = tab->at_freeze_min_age;
2652+
vacstmt.scan_all = tab->at_wraparound;
26522653
vacstmt.verbose = false;
26532654
vacstmt.relation = NULL; /* not used since we pass a relid */
26542655
vacstmt.va_cols = NIL;

src/include/nodes/parsenodes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
1414
* Portions Copyright (c) 1994, Regents of the University of California
1515
*
16-
* $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.379 2008/11/24 08:46:04 petere Exp $
16+
* $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.380 2008/12/04 11:42:24 heikki Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -1966,6 +1966,7 @@ typedef struct VacuumStmt
19661966
bool full; /* do FULL (non-concurrent) vacuum */
19671967
bool analyze; /* do ANALYZE step */
19681968
bool verbose; /* print progress info */
1969+
bool scan_all; /* force scan of all pages */
19691970
int freeze_min_age; /* min freeze age, or -1 to use default */
19701971
RangeVar *relation; /* single table to process, or NULL */
19711972
List *va_cols; /* list of column names, or NIL for all */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy