Re: \gexec \watch

From: Oleksii Kliukin <alexk(at)hintbits(dot)com>
To: Álvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: David Fetter <david(at)fetter(dot)org>, Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: \gexec \watch
Date: 2018-12-06 11:26:08
Message-ID: 0FB1839B-B6D8-4FF6-89F3-AC5BA64864C6@hintbits.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 6. Dec 2018, at 09:01, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> wrote:
>
> On 2018-Dec-06, David Fetter wrote:
>
>> There's a bit of a philosophical issue here, or a mathematical one,
>> whichever way you want to put it. Does it actually make sense to have
>> the behavior of one "semicolon" spill onto another?
>
> Honestly, I don't see the mathematicality in this. It either works, or
> it doesn't -- and from my POV right now it doesn't. Are you saying we
> need a \gexecwatch for this to work?

I’ve been trying to do similar stuff with periodic execution of \gexec (changing the tablespace of all tables in the given one and retrying, since some of them could only get a lock on subsequent attempts) and generally reverted to a bash loop outside of psql, but having it built-in would be great.

Perhaps a numeric argument to \gexec, i.e. \gexec 5 to re-execute the output of a query every 5 seconds?

The other question is whether such a command would execute the original query every time watch is invoked. Consider, e.g. the following one:

select format('select now() as execution_time, %L as generation_time', now()) \gexec
execution_time | 2018-12-06 12:15:24.136086+01
generation_time | 2018-12-06 12:15:24.13577+01

If we make \gexec + \watch combination re-execute only the output of the original query (without the query itself), then the generation time column will stay constant through all \watch invocations.

Cheers,
Oleksii

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2018-12-06 11:39:02 Re: Hint and detail punctuation
Previous Message Daniel Gustafsson 2018-12-06 08:42:26 Re: Hint and detail punctuation