Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion bin/pgcompacttable
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ my $initial_reindex;
my $no_initial_vacuum;

my %table_info;
my $statement_timeout;

unless (GetOptions(
#help & man
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -2132,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
Expand Down