From f91bdeabfc397ebc5124dd8faf6b0d3ec1fcdbc4 Mon Sep 17 00:00:00 2001 From: dog Date: Sun, 27 Aug 2023 11:53:09 +0200 Subject: [PATCH 1/2] edit - PgCompactTable - add option for statement_timeout --- bin/pgcompacttable | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/pgcompacttable b/bin/pgcompacttable index 5fa83b0..714f135 100755 --- a/bin/pgcompacttable +++ b/bin/pgcompacttable @@ -85,6 +85,7 @@ my $initial_reindex; my $no_initial_vacuum; my %table_info; +my $statement_timeout; unless (GetOptions( #help & man @@ -119,7 +120,8 @@ unless (GetOptions( 'a|all' => \$all_db, 'N|exclude-schema=s' => \$exclude_schema, 'T|exclude-table=s' => \$exclude_table, - 'i|initial-reindex' => \$initial_reindex + 'i|initial-reindex' => \$initial_reindex, + 'statement_timeout=i' => \$statement_timeout )) { show_usage(); exit(0); @@ -1294,6 +1296,15 @@ sub process { return -1; } + if ($statement_timeout) { + my $sth0 = _dbh->do("set statement_timeout = $statement_timeout"); + if ($DBI::err) { + logger(LOG_ERROR, "Set statement_timeout error."); + return -1; + } + logger(LOG_NOTICE, "Set statement_timeout = %d", $statement_timeout); + } + $table_info->{stats} = get_size_stats($schema_name, $table_name); if ($DBI::err) { From 0937e2a7be14e91bace7c22b40af9fef22ddaaef Mon Sep 17 00:00:00 2001 From: dog Date: Sun, 27 Aug 2023 16:29:06 +0200 Subject: [PATCH 2/2] edit - PgCompactTable - man for statement_timeout --- bin/pgcompacttable | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/pgcompacttable b/bin/pgcompacttable index 714f135..e7fdf57 100755 --- a/bin/pgcompacttable +++ b/bin/pgcompacttable @@ -2143,6 +2143,12 @@ A maximum number of retries in case of unsuccessful processing. By default 10. =back +=item B<--statement_timeout> TIMEOUT + +Sets the maximum execution time for SQL operators (in milliseconds). By default, the timeout set for Postgres is used. + +=back + =cut =head1 LICENSE AND COPYRIGHT