I saw a comment on a stackoverflow post by the package author (What is the proper way to use the node.js postgresql module?) saying that the best way is to use pg.connect each time. I was wondering if that method is different from the examples he mentioned on the npm website (https://www.npmjs.com/package/pg)?
It seems to me if I follow your post on stackoverflow, then if there are 1000 database accesses by different clients during peak periods, then 1000 different database client connections will be created and there might be a risk of the database crashing (lack of RAM). Also, does this method (just using pg.connect each time) have a pool of connections where the connections are re-used and where there are only a maximum number of connections set by pg.defaults.poolSize. Please correct me if I am wrong?