Database Reference
In-Depth Information
As new connections/transactions/statements arrive, the pool will increase in size up to the
defined user maximums. Those connections will stay around for at most server_idle_timeout
before the pool releases those connections.
pgbouncer also releases sessions every
server_lifetime
. This allows the server to free
backends in rotation to avoid issues with very long-lived session connections.
There's more...
It's possible to connect to pgbouncer itself to issue commands. This can be done interactively
as if you were entering psql, or it can be done using single commands or scripts.
To shut down the server, we can just type
SHUTDOWN
, or enter a single command as follows:
psql -p 6543 pgbouncer -c "SHUTDOWN"
You can also use the command
RELOAD
to make the server reload (that means reread) the
parameter files.
If you are using
pool_mode
=
transaction
or
pool_mode
=
statement
, then you can use
the
PAUSE
command. This allows the current transaction to complete before holding further
work on that session. This allows you to perform DDL more easily or restart the server.
pbouncer also allows you to use SUSPEND mode. This waits for all server-side buffers to flush.
PAUSE
or
SUSPEND
should eventually be followed by
RESUME
when the work is done.
In addition to the pgbouncer control commands, there are also a selection of
SHOW
commands:
Show command
Result set
SHOW STATS
Traffic stats. Total and avg requests, query duration, bytes sent/received.
SHOW SERVERS
One row per connection to database server
SHOW CLIENTS
One row per connection from client
SHOW POOLS
One user per pool of users
SHOW LISTS
Gives a good summary of resource totals
SHOW USERS
Lists uses in
user.txt
SHOW DATABASES
Lists databases in
pgbouncer.ini
SHOW CONFIG
Lists configuration parameters
SHOW FDS
Show file descriptors
SHOW SOCKETS
Show file sockets
SHOW VERSION
pgbouncer version