We recommend using PgBouncer with `session` pool mode instead. You can use the
We recommend using PgBouncer with `session` pool mode. You can use the
[bundled PgBouncer](../postgresql/pgbouncer.md) or use an external PgBouncer and [configure it
[bundled PgBouncer](../postgresql/pgbouncer.md) or use an external PgBouncer and [configure it
manually](https://www.pgbouncer.org/config.html).
manually](https://www.pgbouncer.org/config.html).
The following example uses the bundled PgBouncer and sets up two separate connection pools,
The following example uses the bundled PgBouncer and sets up two separate connection pools on PostgreSQL host,
one in `session` pool mode and the other in `transaction` pool mode. For this example to work,
one in `session` pool mode and the other in `transaction` pool mode. For this example to work,
you need to prepare PostgreSQL server with [setup instruction](#manual-database-setup):
you need to prepare PostgreSQL server as documented in [in the setup instructions](#manual-database-setup):
```ruby
```ruby
pgbouncer['databases']={
pgbouncer['databases']={
...
@@ -389,6 +370,29 @@ your databases manually and configuring an external PgBouncer, you must include
...
@@ -389,6 +370,29 @@ your databases manually and configuring an external PgBouncer, you must include
its password in the file used by PgBouncer. For example, `userlist.txt` if the [`auth_file`](https://www.pgbouncer.org/config.html#auth_file)
its password in the file used by PgBouncer. For example, `userlist.txt` if the [`auth_file`](https://www.pgbouncer.org/config.html#auth_file)
configuration option is set. For more details, consult the PgBouncer documentation.
configuration option is set. For more details, consult the PgBouncer documentation.
#### Configure Praefect to connect directly to PostgreSQL
As an alternative to configuring PgBouncer with `session` pool mode, Praefect can be configured to use different connection parameters for direct access
to PostgreSQL. This is the connection that supports the `LISTEN` feature.
An example of Praefect configuration that bypasses PgBouncer and directly connects to PostgreSQL:
```ruby
praefect['database_direct_host']=POSTGRESQL_HOST
praefect['database_direct_port']=5432
# Use the following to override parameters of direct database connection.
# Comment out where the parameters are the same for both connections.