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

From Pavel Stehule
Subject Re: \gexec \watch
Date
Msg-id CAFj8pRBD9tiZY4yWhyy712+xQ5J7QJAj_HknL7kKwu4=a_eGgQ@mail.gmail.com
Whole thread Raw
In response to Re: \gexec \watch  (Oleksii Kliukin <alexk@hintbits.com>)
Responses Re: \gexec \watch  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers


čt 6. 12. 2018 v 12:26 odesílatel Oleksii Kliukin <alexk@hintbits.com> napsal:


> 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 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?

looks not intuitive :)  


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.

It is better to introduce new command like \gexec_repeat with units like 5s, or how much 5x -

Regards

Pavel

 

Cheers,
Oleksii

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Hint and detail punctuation
Next
From: Alvaro Herrera
Date:
Subject: Re: Hint and detail punctuation