Re: persistent db connections/resiliency

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Boyd <rboyd(at)ivmg(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: persistent db connections/resiliency
Date: 2000-10-09 22:23:34
Message-ID: 7616.971130214@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Robert Boyd <rboyd(at)ivmg(dot)net> writes:
> Should I get connection status before every query, and if bad, attempt
> reconnect?

Waste of time, assuming you are thinking of PQstatus(); it just returns
a field from the PGconn struct showing the last known state.

I'd suggest that *upon error* you check to see if the error indicates
a dead connection, and attempt reconnect if so. No need to expend
cycles in the main line of your app for this.

If you really want an end-to-end connectivity check, you can issue
an empty query string with PQexec; but I'd not recommend doing that
for every single query...

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2000-10-09 22:35:05 Re: Change/convert encoding?
Previous Message Tom Lane 2000-10-09 21:58:49 Re: pg_hba.conf