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

Commit24d2d38

Browse files
author
Amit Kapila
committed
Fix the usage of parallel and full options of vacuum command.
Earlier we were inconsistent in allowing the usage of parallel andfull options. Change it such that we disallow them only when they arecombined in a way that we don't support.In passing, improve the comments in some of the existing tests of parallelvacuum.Reported-by: Tushar AhujaAuthor: Justin Pryzby, Amit KapilaReviewed-by: Sawada Masahiko, Michael Paquier, Mahendra Singh Thalor andAmit KapilaDiscussion:https://postgr.es/m/58c8d171-e665-6fa3-a9d3-d9423b694dae%40enterprisedb.com
1 parent542d781 commit24d2d38

File tree

4 files changed

+26
-23
lines changed

4 files changed

+26
-23
lines changed

‎doc/src/sgml/ref/vacuum.sgml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -235,22 +235,22 @@ VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] [ ANALYZE ] [ <replaceable class="paramet
235235
Perform index vacuum and index cleanup phases of <command>VACUUM</command>
236236
in parallel using <replaceable class="parameter">integer</replaceable>
237237
background workers (for the details of each vacuum phase, please
238-
refer to <xref linkend="vacuum-phases"/>).If the
239-
<literal>PARALLEL</literal> option is omitted, then thenumber of workers
240-
isdetermined based onthe number ofindexes that support parallel vacuum
241-
operation on the relation, and is further limited by <xref
242-
linkend="guc-max-parallel-workers-maintenance"/>.
243-
An indexcan participate in parallel vacuum if and only if the size
244-
of the index ismore than <xref linkend="guc-min-parallel-index-scan-size"/>.
245-
Please notethat it is not guaranteed that the number of parallel workers
246-
specified in<replaceable class="parameter">integer</replaceable> will
247-
be used duringexecution. It is possible for a vacuum to run with fewer
248-
workers thanspecified, or even with no workers at all. Only one worker
249-
can be used perindex. So parallel workers are launched only when there
250-
are at least<literal>2</literal> indexes in the table. Workers for
251-
vacuum are launchedbefore the start of each phase and exit at the end of
252-
the phase. Thesebehaviors might change in a future release. This
253-
option can't be used withthe <literal>FULL</literal> option.
238+
refer to <xref linkend="vacuum-phases"/>).In plain <command>VACUUM</command>
239+
(without<literal>FULL</literal>), if the<literal>PARALLEL</literal> option
240+
isomitted, thenthe number ofworkers is determined based on the number of
241+
indexes on the relation that support parallel vacuum operation and is further
242+
limited by <xreflinkend="guc-max-parallel-workers-maintenance"/>. An index
243+
can participate in parallel vacuum if and only if the size of the index is
244+
more than <xref linkend="guc-min-parallel-index-scan-size"/>. Please note
245+
that it is not guaranteed that the number of parallel workers specified in
246+
<replaceable class="parameter">integer</replaceable> will be used during
247+
execution. It is possible for a vacuum to run with fewer workers than
248+
specified, or even with no workers at all. Only one worker can be used per
249+
index. So parallel workers are launched only when there are at least
250+
<literal>2</literal> indexes in the table. Workers for vacuum are launched
251+
before the start of each phase and exit at the end of the phase. These
252+
behaviors might change in a future release. This option can't be used with
253+
the <literal>FULL</literal> option.
254254
</para>
255255
</listitem>
256256
</varlistentry>

‎src/backend/commands/vacuum.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel)
104104
boolfreeze= false;
105105
boolfull= false;
106106
booldisable_page_skipping= false;
107-
boolparallel_option= false;
108107
ListCell*lc;
109108

110109
/* Set default value */
@@ -145,7 +144,6 @@ ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel)
145144
params.truncate=get_vacopt_ternary_value(opt);
146145
elseif (strcmp(opt->defname,"parallel")==0)
147146
{
148-
parallel_option= true;
149147
if (opt->arg==NULL)
150148
{
151149
ereport(ERROR,
@@ -199,10 +197,10 @@ ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel)
199197
!(params.options& (VACOPT_FULL |VACOPT_FREEZE)));
200198
Assert(!(params.options&VACOPT_SKIPTOAST));
201199

202-
if ((params.options&VACOPT_FULL)&&parallel_option)
200+
if ((params.options&VACOPT_FULL)&&params.nworkers>0)
203201
ereport(ERROR,
204202
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
205-
errmsg("cannot specify both FULL and PARALLEL options")));
203+
errmsg("VACUUM FULL cannot be performed in parallel")));
206204

207205
/*
208206
* Make sure VACOPT_ANALYZE is specified if any column lists are present.

‎src/test/regress/expected/vacuum.out

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,17 @@ LINE 1: VACUUM (PARALLEL -1) pvactst;
115115
^
116116
VACUUM (PARALLEL 2, INDEX_CLEANUP FALSE) pvactst;
117117
VACUUM (PARALLEL 2, FULL TRUE) pvactst; -- error, cannot use both PARALLEL and FULL
118-
ERROR:cannot specify both FULL and PARALLEL options
118+
ERROR:VACUUM FULL cannot be performed in parallel
119119
VACUUM (PARALLEL) pvactst; -- error, cannot use PARALLEL option without parallel degree
120120
ERROR: parallel option requires a value between 0 and 1024
121121
LINE 1: VACUUM (PARALLEL) pvactst;
122122
^
123+
-- Test different combinations of parallel and full options for temporary tables
123124
CREATE TEMPORARY TABLE tmp (a int PRIMARY KEY);
124125
CREATE INDEX tmp_idx1 ON tmp (a);
125-
VACUUM (PARALLEL 1) tmp; --disablesparallel vacuumoption
126+
VACUUM (PARALLEL 1, FULL FALSE) tmp; -- parallel vacuumdisabled for temp tables
126127
WARNING: disabling parallel option of vacuum on "tmp" --- cannot vacuum temporary tables in parallel
128+
VACUUM (PARALLEL 0, FULL TRUE) tmp; -- can specify parallel disabled (even though that's implied by FULL)
127129
RESET min_parallel_index_scan_size;
128130
DROP TABLE pvactst;
129131
-- INDEX_CLEANUP option

‎src/test/regress/sql/vacuum.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,12 @@ VACUUM (PARALLEL -1) pvactst; -- error
100100
VACUUM (PARALLEL2, INDEX_CLEANUP FALSE) pvactst;
101101
VACUUM (PARALLEL2, FULL TRUE) pvactst;-- error, cannot use both PARALLEL and FULL
102102
VACUUM (PARALLEL) pvactst;-- error, cannot use PARALLEL option without parallel degree
103+
104+
-- Test different combinations of parallel and full options for temporary tables
103105
CREATE TEMPORARY TABLE tmp (aintPRIMARY KEY);
104106
CREATEINDEXtmp_idx1ON tmp (a);
105-
VACUUM (PARALLEL1) tmp;-- disables parallel vacuum option
107+
VACUUM (PARALLEL1, FULL FALSE) tmp;-- parallel vacuum disabled for temp tables
108+
VACUUM (PARALLEL0, FULL TRUE) tmp;-- can specify parallel disabled (even though that's implied by FULL)
106109
RESET min_parallel_index_scan_size;
107110
DROPTABLE pvactst;
108111

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp