A structure to control timeouts for PosrgreSQL queries
There are two parameters, execute
and statement
.
execute
parameter controls the overall time the driver spends executing a query, that includes:
- connecting to PostgreSQL server, if there are no connections available and connection pool still has space for new connections;
- waiting for a connection to become idle if there are no idle connections and connection pool already has reached it's max size;
- preparing a statement if the statement is run for the first time on the connection;
- binding parameters and executing the statement;
- waiting for the first results to arrive from the server. If the result set is big, only time to the first data packet is taken into account.
statement
is rather straightforward, it's the PostgreSQL server-side parameter, and it controls the time the database backend can spend executing a single statement. It is very costly to change the statement timeout often, as it requires a roundtrip to the database to change the setting.
- See also
- https://www.postgresql.org/docs/12/runtime-config-client.html
execute
timeout should always be greater than the statement
timeout!
In case of a timeout, either back-end or overall, the client gets an exception and the driver tries to clean up the connection for further reuse.
- Examples
- postgresql/functional_tests/basic_chaos/postgres_service.cpp.
Definition at line 111 of file options.hpp.