Re: [PATCH] Connection time for \conninfo

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Rodrigo Ramírez Norambuena <decipher(dot)hk(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Connection time for \conninfo
Date: 2019-09-04 03:06:04
Message-ID: 20190904030604.GA2170@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Sep 03, 2019 at 10:13:57PM -0400, Rodrigo Ramírez Norambuena wrote:
> I've work in the a little patch to add into the \conninfo of psql
> command the connection time against a server backend
>
> Maybe could add after, the precheck to if the connection is alive.
> I've take first look to the pqPacketSend, my idea is send a ECHO
> packet over to the database connection. If someone has a better idea
> it would be great to know.

You can do basically the same thing by looking at
pg_stat_activity.backend_start and compare it with the clock
timestamp. Doing it at SQL level the way you want has also the
advantage to offer you a modular format output.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2019-09-04 03:44:20 Re: [HACKERS] Transactions involving multiple postgres foreign servers, take 2
Previous Message Rodrigo Ramírez Norambuena 2019-09-04 02:13:57 [PATCH] Connection time for \conninfo