I'm no node.js professional, but this looks like it establishes a new connection for each query? This is a pretty bad idea, not only are you going to add a ton of latency here for SSL connection negotiation + setup, the postgres server forks per connection so you're going to cause undue load on the server. I'd suggest some kind of connection pool here.