【问题标题】:node-pg-pool: How can specify the max size in Poolnode-pg-pool:如何在 Pool 中指定最大大小
【发布时间】:2018-01-18 11:58:14
【问题描述】:
【问题讨论】:
标签:
postgresql
connection-pooling
amazon-rds
node-pg-pool
【解决方案1】:
当我使用以下代码连接到 Elephantsql 上的 postgres 数据库时,我成功设置了池大小,aws 应该类似。顺便说一句,您如何连接到 AWS RDS?因为我遇到了很多麻烦
var poolConfig = {
max: 5, //connections (was 20 in brianc's repo)
min: 2, //connections (was 4 in brianc's repo)
idleTimeoutMillis: 1000 //close idle clients after 1 second
}
poolConfig.user = 'aaaa';
poolConfig.password = 'bbbb';
poolConfig.database = 'ccccc';
poolConfig.host = 'ddddd';
poolConfig.port = 5432;
poolConfig.ssl = true;
var pool = new Pool(poolConfig);
pool.connect().then(client => {
client.query("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';")
.then(data=>{});