I want to execute a script that will perform a lot of queries and I use pg to manage the connections. The problem is that when my pool is full, my program stops and doesn't queue the future queries. I try to set the poolSize at 0 but it doesn't work either.
pg.defaults.poolSize = 100000000;
var pgQuery = function(query) {
return new Promise(function(resolve, reject) {
pg.connect(conString, function(err, client) { // When the pool is full, pg doesn't connect to the DB
if(err) {
console.error('error fetching client from pool', err);
reject(err);
}
client.query(query,
function(err, res) {
if(err) {
console.error('error running query', err);
reject(err);
}
resolve(res);
});
});
});
};
Any suggestions?