Re: \gexec \watch - Mailing list pgsql-hackers

From Oleksii Kliukin
Subject Re: \gexec \watch
Date
Msg-id 0FB1839B-B6D8-4FF6-89F3-AC5BA64864C6@hintbits.com
Whole thread Raw
In response to Re: \gexec \watch  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: \gexec \watch  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: \gexec \watch  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers

> On 6. Dec 2018, at 09:01, Alvaro Herrera <alvherre@2ndquadrant.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
givenone and retrying, since some of them could only get a lock on subsequent attempts)  and generally reverted to a
bashloop 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),
thenthe generation time column will stay constant through all \watch invocations. 

Cheers,
Oleksii

pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: Hint and detail punctuation
Next
From: Michael Paquier
Date:
Subject: Re: Hint and detail punctuation