Node-postgres: setting the maximum connection pool size

I can’t find the documentation for the node-postgres disk when I configure the maximum size of the connection pool, or even figure out what it is if it is not configured. Does anyone know how I can set the maximum number of connections or what is the default?

+8
postgresql connection-pooling
source share
2 answers

default values ​​are defined in node-postgres / lib / defaults https://github.com/brianc/node-postgres/blob/master/lib/defaults.js

poolSize is set to 10 by default; 0 will disable any pool.

var pg = require('pg'); pg.defaults.poolSize = 20; 

Please note that the pool is used only when using the connect method, and not when starting a client instance directly.

+11
source share

node.js is single threaded, why do I need to have more than 1 db connection per process? Even if you will cluster node.js processes, you should have 1 connection per max process. Otherwise, you are doing something wrong.

-3
source share

All Articles