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

Commit4d8a8d0

Browse files
author
Amit Kapila
committed
Introduce IndexAM fields for parallel vacuum.
Introduce new fields amusemaintenanceworkmem and amparallelvacuumoptionsin IndexAmRoutine for parallel vacuum. The amusemaintenanceworkmem tellswhether a particular IndexAM uses maintenance_work_mem or not. This willhelp in controlling the memory used by individual workers as otherwise,each worker can consume memory equal to maintenance_work_mem. Theamparallelvacuumoptions tell whether a particular IndexAM participates ina parallel vacuum and if so in which phase (bulkdelete, vacuumcleanup) ofvacuum.Author: Masahiko Sawada and Amit KapilaReviewed-by: Dilip Kumar, Amit Kapila, Tomas Vondra and Robert HaasDiscussion:https://postgr.es/m/CAD21AoDTPMgzSkV4E3SFo1CH_x50bf5PqZFQf4jmqjk-C03BWg@mail.gmail.comhttps://postgr.es/m/CAA4eK1LmcD5aPogzwim5Nn58Ki+74a6Edghx4Wd8hAskvHaq5A@mail.gmail.com
1 parentfe23336 commit4d8a8d0

File tree

11 files changed

+75
-0
lines changed

11 files changed

+75
-0
lines changed

‎contrib/bloom/blutils.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include"access/reloptions.h"
1919
#include"bloom.h"
2020
#include"catalog/index.h"
21+
#include"commands/vacuum.h"
2122
#include"miscadmin.h"
2223
#include"storage/bufmgr.h"
2324
#include"storage/freespace.h"
@@ -121,6 +122,9 @@ blhandler(PG_FUNCTION_ARGS)
121122
amroutine->ampredlocks= false;
122123
amroutine->amcanparallel= false;
123124
amroutine->amcaninclude= false;
125+
amroutine->amusemaintenanceworkmem= false;
126+
amroutine->amparallelvacuumoptions=
127+
VACUUM_OPTION_PARALLEL_BULKDEL |VACUUM_OPTION_PARALLEL_CLEANUP;
124128
amroutine->amkeytype=InvalidOid;
125129

126130
amroutine->ambuild=blbuild;

‎doc/src/sgml/indexam.sgml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ typedef struct IndexAmRoutine
122122
bool amcanparallel;
123123
/* does AM support columns included with clause INCLUDE? */
124124
bool amcaninclude;
125+
/* does AM use maintenance_work_mem? */
126+
bool amusemaintenanceworkmem;
127+
/* OR of parallel vacuum flags */
128+
uint8 amparallelvacuumoptions;
125129
/* type of data stored in index, or InvalidOid if variable */
126130
Oid amkeytype;
127131

‎src/backend/access/brin/brin.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include"access/xloginsert.h"
2828
#include"catalog/index.h"
2929
#include"catalog/pg_am.h"
30+
#include"commands/vacuum.h"
3031
#include"miscadmin.h"
3132
#include"pgstat.h"
3233
#include"postmaster/autovacuum.h"
@@ -101,6 +102,9 @@ brinhandler(PG_FUNCTION_ARGS)
101102
amroutine->ampredlocks= false;
102103
amroutine->amcanparallel= false;
103104
amroutine->amcaninclude= false;
105+
amroutine->amusemaintenanceworkmem= false;
106+
amroutine->amparallelvacuumoptions=
107+
VACUUM_OPTION_PARALLEL_CLEANUP;
104108
amroutine->amkeytype=InvalidOid;
105109

106110
amroutine->ambuild=brinbuild;

‎src/backend/access/gin/ginutil.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include"access/xloginsert.h"
2121
#include"catalog/pg_collation.h"
2222
#include"catalog/pg_type.h"
23+
#include"commands/vacuum.h"
2324
#include"miscadmin.h"
2425
#include"storage/indexfsm.h"
2526
#include"storage/lmgr.h"
@@ -53,6 +54,9 @@ ginhandler(PG_FUNCTION_ARGS)
5354
amroutine->ampredlocks= true;
5455
amroutine->amcanparallel= false;
5556
amroutine->amcaninclude= false;
57+
amroutine->amusemaintenanceworkmem= true;
58+
amroutine->amparallelvacuumoptions=
59+
VACUUM_OPTION_PARALLEL_BULKDEL |VACUUM_OPTION_PARALLEL_CLEANUP;
5660
amroutine->amkeytype=InvalidOid;
5761

5862
amroutine->ambuild=ginbuild;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include"access/gist_private.h"
1818
#include"access/gistscan.h"
1919
#include"catalog/pg_collation.h"
20+
#include"commands/vacuum.h"
2021
#include"miscadmin.h"
2122
#include"nodes/execnodes.h"
2223
#include"storage/lmgr.h"
@@ -74,6 +75,9 @@ gisthandler(PG_FUNCTION_ARGS)
7475
amroutine->ampredlocks= true;
7576
amroutine->amcanparallel= false;
7677
amroutine->amcaninclude= true;
78+
amroutine->amusemaintenanceworkmem= false;
79+
amroutine->amparallelvacuumoptions=
80+
VACUUM_OPTION_PARALLEL_BULKDEL |VACUUM_OPTION_PARALLEL_COND_CLEANUP;
7781
amroutine->amkeytype=InvalidOid;
7882

7983
amroutine->ambuild=gistbuild;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ hashhandler(PG_FUNCTION_ARGS)
7272
amroutine->ampredlocks= true;
7373
amroutine->amcanparallel= false;
7474
amroutine->amcaninclude= false;
75+
amroutine->amusemaintenanceworkmem= false;
76+
amroutine->amparallelvacuumoptions=
77+
VACUUM_OPTION_PARALLEL_BULKDEL;
7578
amroutine->amkeytype=INT4OID;
7679

7780
amroutine->ambuild=hashbuild;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ bthandler(PG_FUNCTION_ARGS)
121121
amroutine->ampredlocks= true;
122122
amroutine->amcanparallel= true;
123123
amroutine->amcaninclude= true;
124+
amroutine->amusemaintenanceworkmem= false;
125+
amroutine->amparallelvacuumoptions=
126+
VACUUM_OPTION_PARALLEL_BULKDEL |VACUUM_OPTION_PARALLEL_COND_CLEANUP;
124127
amroutine->amkeytype=InvalidOid;
125128

126129
amroutine->ambuild=btbuild;

‎src/backend/access/spgist/spgutils.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include"access/transam.h"
2323
#include"access/xact.h"
2424
#include"catalog/pg_amop.h"
25+
#include"commands/vacuum.h"
2526
#include"storage/bufmgr.h"
2627
#include"storage/indexfsm.h"
2728
#include"storage/lmgr.h"
@@ -56,6 +57,9 @@ spghandler(PG_FUNCTION_ARGS)
5657
amroutine->ampredlocks= false;
5758
amroutine->amcanparallel= false;
5859
amroutine->amcaninclude= false;
60+
amroutine->amusemaintenanceworkmem= false;
61+
amroutine->amparallelvacuumoptions=
62+
VACUUM_OPTION_PARALLEL_BULKDEL |VACUUM_OPTION_PARALLEL_COND_CLEANUP;
5963
amroutine->amkeytype=InvalidOid;
6064

6165
amroutine->ambuild=spgbuild;

‎src/include/access/amapi.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ typedef struct IndexAmRoutine
197197
boolamcanparallel;
198198
/* does AM support columns included with clause INCLUDE? */
199199
boolamcaninclude;
200+
/* does AM use maintenance_work_mem? */
201+
boolamusemaintenanceworkmem;
202+
/* OR of parallel vacuum flags. See vacuum.h for flags. */
203+
uint8amparallelvacuumoptions;
200204
/* type of data stored in index, or InvalidOid if variable */
201205
Oidamkeytype;
202206

‎src/include/commands/vacuum.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,44 @@
2323
#include"storage/lock.h"
2424
#include"utils/relcache.h"
2525

26+
/*
27+
* Flags for amparallelvacuumoptions to control the participation of bulkdelete
28+
* and vacuumcleanup in parallel vacuum.
29+
*/
30+
31+
/*
32+
* Both bulkdelete and vacuumcleanup are disabled by default. This will be
33+
* used by IndexAM's that don't want to or cannot participate in parallel
34+
* vacuum. For example, if an index AM doesn't have a way to communicate the
35+
* index statistics allocated by the first ambulkdelete call to the subsequent
36+
* ones until amvacuumcleanup, the index AM cannot participate in parallel
37+
* vacuum.
38+
*/
39+
#defineVACUUM_OPTION_NO_PARALLEL0
40+
41+
/*
42+
* bulkdelete can be performed in parallel. This option can be used by
43+
* IndexAm's that need to scan the index to delete the tuples.
44+
*/
45+
#defineVACUUM_OPTION_PARALLEL_BULKDEL(1 << 0)
46+
47+
/*
48+
* vacuumcleanup can be performed in parallel if bulkdelete is not performed
49+
* yet. This will be used by IndexAM's that can scan the index if the
50+
* bulkdelete is not performed.
51+
*/
52+
#defineVACUUM_OPTION_PARALLEL_COND_CLEANUP(1 << 1)
53+
54+
/*
55+
* vacuumcleanup can be performed in parallel even if bulkdelete has already
56+
* processed the index. This will be used by IndexAM's that scan the index
57+
* during the cleanup phase of index irrespective of whether the index is
58+
* already scanned or not during bulkdelete phase.
59+
*/
60+
#defineVACUUM_OPTION_PARALLEL_CLEANUP(1 << 2)
61+
62+
/* value for checking vacuum flags */
63+
#defineVACUUM_OPTION_MAX_VALID_VALUE((1 << 3) - 1)
2664

2765
/*----------
2866
* ANALYZE builds one of these structs for each attribute (column) that is

‎src/test/modules/dummy_index_am/dummy_index_am.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include"access/amapi.h"
1717
#include"access/reloptions.h"
1818
#include"catalog/index.h"
19+
#include"commands/vacuum.h"
1920
#include"nodes/pathnodes.h"
2021
#include"utils/guc.h"
2122
#include"utils/rel.h"
@@ -294,6 +295,8 @@ dihandler(PG_FUNCTION_ARGS)
294295
amroutine->ampredlocks= false;
295296
amroutine->amcanparallel= false;
296297
amroutine->amcaninclude= false;
298+
amroutine->amusemaintenanceworkmem= false;
299+
amroutine->amparallelvacuumoptions=VACUUM_OPTION_NO_PARALLEL;
297300
amroutine->amkeytype=InvalidOid;
298301

299302
amroutine->ambuild=dibuild;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp