Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node-postgres: Setting max connection pool size

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?

like image 721
Jake Avatar asked Apr 18 '12 15:04

Jake


People also ask

How do I change the max connections in PostgreSQL?

Firstly, run the following command in a Postgres console: alter system set max_connections = 30; (or whatever number of connections you'd like). Next, you need to restart your Postgres server.

How many max connections can Postgres handle?

PostgreSQL Connection Limits 15 connections are reserved for the superuser to maintain the state and integrity of your database, and 100 connections are available for you and your applications.


1 Answers

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.

like image 60
Krut Avatar answered Oct 18 '22 03:10

Krut