node-postgres: Setting max connection pool size

connection-pooling, node.js, postgresql

Solution

defaults 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 pooling.

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

Note that the pool is only used when using the connect method, and not when initiating an instance of Client directly.

Problem

I can't find any documentation for the node-postgres drive on setting the maximum connection pool size, or even finding out what it is if it's not configurable. Does anyone know how I can set the maximum number of connections, or what it is by default?

Original source