Abhay Gupta <gupta.abhay86@gmail.com> writes:
> we are noticing the connection establishment is taking around 200-300 ms.
Not sure whether that's out of line or not, since you've provided
no background data (e.g. is the connection across a network link?
how busy is the server? what encryption and authentication are
you using?). However ...
> The connection establishment time is very high as our functions are written
> to be very high performance.
... if you are looking for good performance, the last thing you
should be doing is making a connection per query. Postgres backend
processes are pretty heavyweight things. Even after the connection
is complete, there's overhead involved in populating caches and so
forth. You'd be well-served to use a connection pooler and/or try
to keep an application's connection open once made.
regards, tom lane