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

Commitae78cae

Browse files
committed
Add --buffer-usage-limit option to vacuumdb
1cbbee0 added BUFFER_USAGE_LIMIT to the VACUUM and ANALYZE commands, sohere we permit that option to be specified in vacuumdb.In passing, adjust the documents for vacuum_buffer_usage_limit and theBUFFER_USAGE_LIMIT VACUUM option to mention "kB" rather than "KB". Do thesame for the ERROR message in ExecVacuum() andcheck_vacuum_buffer_usage_limit(). Without that we might tell a user thatthe valid minimum value is 128 KB only to reject that because we acceptonly "kB" and not "KB".Also, add a small reminder comment in vacuum.h to try to trigger thememory of anyone adding new fields to VacuumParams that they might want toconsider if vacuumdb needs to grow a new option too.Author: Melanie PlagemanReviewed-by: Justin PryzbyReviewed-by: David RowleyDiscussion:https://postgr.es/m/ZAzTg3iEnubscvbf@telsasoft.com
1 parent00d1e02 commitae78cae

File tree

6 files changed

+48
-6
lines changed

6 files changed

+48
-6
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,10 +2015,10 @@ include_dir 'conf.d'
20152015
used by the <command>VACUUM</command> and <command>ANALYZE</command>
20162016
commands. A setting of <literal>0</literal> will allow the operation
20172017
to use any number of <varname>shared_buffers</varname>. Otherwise
2018-
valid sizes range from <literal>128KB</literal> to
2018+
valid sizes range from <literal>128kB</literal> to
20192019
<literal>16 GB</literal>. If the specified size would exceed 1/8 the
20202020
size of <varname>shared_buffers</varname>, the size is silently capped
2021-
to that value. The default value is <literal>256KB</literal>. If
2021+
to that value. The default value is <literal>256kB</literal>. If
20222022
this value is specified without units, it is taken as kilobytes. This
20232023
parameter can be set at any time. It can be overridden for
20242024
<xref linkend="sql-vacuum"/> and <xref linkend="sql-analyze"/>

‎doc/src/sgml/ref/vacuumdb.sgml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,19 @@ PostgreSQL documentation
278278
</listitem>
279279
</varlistentry>
280280

281+
<varlistentry>
282+
<term><option>--buffer-usage-limit <replaceable class="parameter">buffer_usage_limit</replaceable></option></term>
283+
<listitem>
284+
<para>
285+
Specifies the
286+
<glossterm linkend="glossary-buffer-access-strategy">Buffer Access Strategy</glossterm>
287+
ring buffer size for a given invocation of <application>vacuumdb</application>.
288+
This size is used to calculate the number of shared buffers which will
289+
be reused as part of this strategy. See <xref linkend="sql-vacuum"/>.
290+
</para>
291+
</listitem>
292+
</varlistentry>
293+
281294
<varlistentry>
282295
<term><option>-n <replaceable class="parameter">schema</replaceable></option></term>
283296
<term><option>--schema=<replaceable class="parameter">schema</replaceable></option></term>

‎src/backend/commands/vacuum.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ check_vacuum_buffer_usage_limit(int *newval, void **extra,
135135
return true;
136136

137137
/* Value does not fall within any allowable range */
138-
GUC_check_errdetail("\"vacuum_buffer_usage_limit\" must be 0 or between %dKB and %dKB",
138+
GUC_check_errdetail("\"vacuum_buffer_usage_limit\" must be 0 or between %dkB and %dkB",
139139
MIN_BAS_VAC_RING_SIZE_KB,MAX_BAS_VAC_RING_SIZE_KB);
140140

141141
return false;
@@ -225,7 +225,7 @@ ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel)
225225
{
226226
ereport(ERROR,
227227
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
228-
errmsg("buffer_usage_limit option must be 0 or between %dKB and %dKB",
228+
errmsg("buffer_usage_limit option must be 0 or between %dkB and %dkB",
229229
MIN_BAS_VAC_RING_SIZE_KB,MAX_BAS_VAC_RING_SIZE_KB)));
230230
}
231231

‎src/bin/scripts/vacuumdb.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ typedef struct vacuumingOptions
4646
boolprocess_main;
4747
boolprocess_toast;
4848
boolskip_database_stats;
49+
char*buffer_usage_limit;
4950
}vacuumingOptions;
5051

5152
/* object filter options */
@@ -123,6 +124,7 @@ main(int argc, char *argv[])
123124
{"no-truncate",no_argument,NULL,10},
124125
{"no-process-toast",no_argument,NULL,11},
125126
{"no-process-main",no_argument,NULL,12},
127+
{"buffer-usage-limit",required_argument,NULL,13},
126128
{NULL,0,NULL,0}
127129
};
128130

@@ -147,6 +149,7 @@ main(int argc, char *argv[])
147149
/* initialize options */
148150
memset(&vacopts,0,sizeof(vacopts));
149151
vacopts.parallel_workers=-1;
152+
vacopts.buffer_usage_limit=NULL;
150153
vacopts.no_index_cleanup= false;
151154
vacopts.force_index_cleanup= false;
152155
vacopts.do_truncate= true;
@@ -266,6 +269,9 @@ main(int argc, char *argv[])
266269
case12:
267270
vacopts.process_main= false;
268271
break;
272+
case13:
273+
vacopts.buffer_usage_limit=pg_strdup(optarg);
274+
break;
269275
default:
270276
/* getopt_long already emitted a complaint */
271277
pg_log_error_hint("Try \"%s --help\" for more information.",progname);
@@ -343,6 +349,14 @@ main(int argc, char *argv[])
343349
pg_fatal("cannot use the \"%s\" option with the \"%s\" option",
344350
"no-index-cleanup","force-index-cleanup");
345351

352+
/*
353+
* buffer-usage-limit is not allowed with VACUUM FULL unless ANALYZE is
354+
* included too.
355+
*/
356+
if (vacopts.buffer_usage_limit&&vacopts.full&& !vacopts.and_analyze)
357+
pg_fatal("cannot use the \"%s\" option with the \"%s\" option",
358+
"buffer-usage-limit","full");
359+
346360
/* fill cparams except for dbname, which is set below */
347361
cparams.pghost=host;
348362
cparams.pgport=port;
@@ -550,6 +564,10 @@ vacuum_one_database(ConnParams *cparams,
550564
pg_fatal("cannot use the \"%s\" option on server versions older than PostgreSQL %s",
551565
"--parallel","13");
552566

567+
if (vacopts->buffer_usage_limit&&PQserverVersion(conn)<160000)
568+
pg_fatal("cannot use the \"%s\" option on server versions older than PostgreSQL %s",
569+
"--buffer-usage-limit","16");
570+
553571
/* skip_database_stats is used automatically if server supports it */
554572
vacopts->skip_database_stats= (PQserverVersion(conn) >=160000);
555573

@@ -1048,6 +1066,13 @@ prepare_vacuum_command(PQExpBuffer sql, int serverVersion,
10481066
vacopts->parallel_workers);
10491067
sep=comma;
10501068
}
1069+
if (vacopts->buffer_usage_limit)
1070+
{
1071+
Assert(serverVersion >=160000);
1072+
appendPQExpBuffer(sql,"%sBUFFER_USAGE_LIMIT '%s'",sep,
1073+
vacopts->buffer_usage_limit);
1074+
sep=comma;
1075+
}
10511076
if (sep!=paren)
10521077
appendPQExpBufferChar(sql,')');
10531078
}
@@ -1111,6 +1136,7 @@ help(const char *progname)
11111136
printf(_(" --force-index-cleanup always remove index entries that point to dead tuples\n"));
11121137
printf(_(" -j, --jobs=NUM use this many concurrent connections to vacuum\n"));
11131138
printf(_(" --min-mxid-age=MXID_AGE minimum multixact ID age of tables to vacuum\n"));
1139+
printf(_(" --buffer-usage-limit=BUFSIZE size of ring buffer used for vacuum\n"));
11141140
printf(_(" --min-xid-age=XID_AGE minimum transaction ID age of tables to vacuum\n"));
11151141
printf(_(" --no-index-cleanup don't remove index entries that point to dead tuples\n"));
11161142
printf(_(" --no-process-main skip the main relation\n"));

‎src/include/commands/vacuum.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ typedef enum VacOptValue
213213
*
214214
* Note that at least one of VACOPT_VACUUM and VACOPT_ANALYZE must be set
215215
* in options.
216+
*
217+
* When adding a new VacuumParam member, consider adding it to vacuumdb as
218+
* well.
216219
*/
217220
typedefstructVacuumParams
218221
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,10 @@ VACUUM (BUFFER_USAGE_LIMIT 0) vac_option_tab;
358358
ANALYZE (BUFFER_USAGE_LIMIT 0) vac_option_tab;
359359
-- value exceeds max size error
360360
VACUUM (BUFFER_USAGE_LIMIT 16777220) vac_option_tab;
361-
ERROR: buffer_usage_limit option must be 0 or between 128KB and 16777216KB
361+
ERROR: buffer_usage_limit option must be 0 or between 128kB and 16777216kB
362362
-- value is less than min size error
363363
VACUUM (BUFFER_USAGE_LIMIT 120) vac_option_tab;
364-
ERROR: buffer_usage_limit option must be 0 or between 128KB and 16777216KB
364+
ERROR: buffer_usage_limit option must be 0 or between 128kB and 16777216kB
365365
-- integer overflow error
366366
VACUUM (BUFFER_USAGE_LIMIT 10000000000) vac_option_tab;
367367
ERROR: value: "10000000000": is invalid for buffer_usage_limit

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp