Setup PgBouncer

By default PgBouncer is already available on your Crunchy Bridge instance for you. In order to connect to PgBouncer you need to enable the relevant roles that allow your PgBouncer and Postgres database to talk to each other. You can do this by following the below steps and then connecting to a new port which PgBouncer is running on.

Enable connection pooling

To enable connection pooling for a database, run the following command (needs superuser privileges):

CREATE EXTENSION crunchy_pooler;

Use connection pooling

Only non-superuser roles can connect to the pooler (i.e. do not use the postgres role).

To connect to the pooler, use your cluster’s connection string per usual, except with 5431 for the port number, for example:

psql postgres://appuser:[email protected]:5431/mydb

Remove connection pooling

To disable connection pooling for a database, run DROP EXTENSION.