Posts

Showing posts with the label db connect to pgbouncer
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Check If Your Current Database Is Connected To Pgbouncer Or Not --- In Postgresql

Determining if your current database connection is using PgBouncer, or going directly to Postgres itself, can be challenging, as PgBouncer is a very low-level, transparent interface. It is possible, and here are some detection methods you can use. This was inspired by someone asking on the Perl DBD IRC channel if it was possible to easily tell if your current database handle (usually "$dbh") is connected to PgBouncer or not. Since I've seen this question asked in other venues, I decided to take a crack at it. There are actually two questions to be answered: (1) are we connected to PgBouncer, and if so, (2) what pool_mode is being run? The quickest and easiest way I found to answer the first question is to try and connect to a non-existent database. Normally, this is a FATAL message, as seen here: $ psql testdb -p 5432 testdb=# \c ghostdb FATAL:  database "ghostdb" does not exist Previous connection kept testdb=# However, a slightly different ERROR message is ret...