When you are using PgBouncer with e.g. a Ruby on Rails application which uses different application_name
s for the PostgreSQL connection (for Puma, Sidekiq, Cronjobs, ...) PgBouncer will set the application name accordingly on each statement which is executed.
For example, the first connection to PgBouncer is from Puma using application_name
= puma: cluster worker 3: 123456
. PgBouncer will then execute SET application_name = puma: [...]
before executing the statement.
After this query is done, the next connection to PgBouncer is from Sidekiq, where the application_name
is /path/to/sidekiq
and which uses the same connection from PgBouncer to PostgreSQL.
Then PgBouncer will execute SET application_name = /path/to/sidekiq
before running the Sidekiq Query.
This can happen quite often and take a lot of resources. Due to that you should make sure all parts of your application will use the same application_name
, e.g. by using
PGAPPNAME
Show archive.org snapshot
. Keep in mind you will loose the knowledge of which application executed this query.