pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Abhay Gupta <gupta.abhay86@gmail.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: Azure Postgresql High connection establishment time
Date: Mon, 20 Sep 2021 13:16:20 -0400
Message-ID: <1817783.1632158180@sss.pgh.pa.us> (raw)
In-Reply-To: <CACpkcfw2+OB=B17-DkNC8erAPALYPLErK2opGv6LhKWU+L6f6A@mail.gmail.com>
References: <CACpkcfw2+OB=B17-DkNC8erAPALYPLErK2opGv6LhKWU+L6f6A@mail.gmail.com>

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





view thread (6+ messages)  latest in thread

Message-ID: <1817783.1632158180@sss.pgh.pa.us>
Permalink:  ../1817783.1632158180@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1817783.1632158180@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, gupta.abhay86@gmail.com
  Subject: Re: Azure Postgresql High connection establishment time
  In-Reply-To: <1817783.1632158180@sss.pgh.pa.us>
  References: <CACpkcfw2+OB=B17-DkNC8erAPALYPLErK2opGv6LhKWU+L6f6A@mail.gmail.com> <1817783.1632158180@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox