How I can have two different connection pools for two different databases?
See original GitHub issueIt is possible to set pool size in pg.defaults
. However let’s say I have two databases and two separate connection strings for them:
postgres://localhost/db1
postgres://localhost/db2
And I want to have two different pool sizes for each of them. For example max 20 connections for db1 and max 100 connections for db2. How I can do that? Changing pool size in pg.defaults will set it globally…
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (10 by maintainers)
Top Results From Across the Web
Can I use one pooled datasource for multiple databases ...
If you have 2 databases, DB1 and DB2, and want a connection pool, you need to have prepared connections for both databases. If...
Read more >How to create one Connection Pool for Two Different ...
You create 2 databases in the physical layer, each one with its own connection pool and then you can do your cross joins...
Read more >Connection pooling and multiple databases
We use multiple databases at work and we have a “reporting” connection pool using a particular user account that has select-only access to...
Read more >Multiple connection pools : brief refresh of common rules
You can have multiple connection pools inside the same database object and they can use different database users with different access and ...
Read more >How to create a Multi-Database Pool in HikariCP
This post is about a program you can use if you are using multiple databases, and data sources for connection pooling, using core...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t think it is supported. I recommend using pgbouncer for connection pooling. It is more flexible, faster, mature than the node-postgres connection pooling. There are other options too from the Postgres community. If you use pgbouncer, then you can open/close single connections in your JS code without any significant performance penalty.
You configure
pgbouncer
, have it run as a daemon, and then you make Postgres queries topgbouncer
(default port 6543) in Node.js like normal without using the pooling code like the example in the README: