You're connecting to port 6432
instead of PostgreSQL default 5432
. Are you connecting to PostgresqL via PgBouncer?
If you're running PgBouncer in pool_mode=transaction
, that would explain the behavior you're seeing. This is because the transaction mode of the PgBouncer will reset the state of the connection between each query. In practice, the query set statement_timeout = 0;
is executed successfully and does have effect. After that PgBouncer resets the state before executing the next query show statement_timeout;
which obviously will show the default state after the reset. And similarly if you try to run
set statement_timeout = 0; vacuum analyze;
the VACUUM
will be executed after resetting the connection state and that will use the default timeout, too.
When you use pool mode transaction, you should typically run only full transactions such as begin; set LOCAL statement_timeout = 0; ...; commit
but vacuum
cannot be run within a transaction which prevents using this solution for executing vacuum analyze
.
Probably the best solution is to connect to PostgreSQL directly, instead of using PgBouncer in between. That would allow setting the statement_timeout only for that connection and successfully allow running the vacuum analyze
. If you cannot do that, you have to set database or role specific default value for the timeout instead and simply use the default value for the connection while using pool mode transaction for the PgBouncer.