Search code examples
azurepgbouncerazure-database-postgresql

PGBouncer-Azure Database for PostgreSQL Flexible Server


I created a new database in Flexible Server and enabled the pgbouncer. When I run SHOW DATABASE, it only displays two databases. How to assign a newly created database to pgbouncer.please find the screenshot

1


Solution

  • I created one Azure PostgreSQL database Flexible server by enabling pgbouncer like below:-

    enter image description here

    I tried running SHOW DATABASES; command in pgbouncer and received 2 default databases, Refer below:-

    enter image description here

    By default when pgbouncer does not include CREATE DATABASE command when I ran SHOW HELP; Refer below:-

    enter image description here

    SHOW DATABASES will only show the currently applied connection limits to the databases, As the newly created database does not have any connection limit applied, It is not showing under SHOW DATABASES; result. In order for database to reflect you need to set the Connection limit parameter to the Database with Alter command.

    I connected to testdb that I created and assigned a connection limit to the testdb like below:-

    Create testdb:-

    CREATE DATABASE testdb;
    

    enter image description here

    Connected to testdb Note- to connect any database to pgbouncer you need to use Port 6432 like below:-

     psql "host=<potgresqlservername>.postgres.database.azure.com port=6432 dbname=testdb user=<username>password=<password> sslmode=require"
    

    enter image description here

    Altered testdb Database Connection limit:-

    ALTER DATABASE testdb CONNECTION LIMIT 100;
    

    enter image description here

    Now, I connected to pgbouncer and ran SHOW DATABASES; and got testdb in the result refer below:-

    enter image description here