Re: \gexec \watch

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: alexk(at)hintbits(dot)com, David Fetter <david(at)fetter(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: \gexec \watch
Date: 2018-12-06 12:56:18
Message-ID: 20181206125618.gtzp4pvkzf7ihobf@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2018-Dec-06, Pavel Stehule wrote:

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

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

It is? \gexec \watch is an elegant construct using two existing atoms
with well-defined semantics. Can't say I see that in \gexec_repeat --
it seems non-orthogonal to me.

To Oleksii's question, I think if you want to repeat the first query
over and over, you'd use something like this:

select format('select now() as execution_time, %L as generation_time', now()) as query \gset
:query \watch

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2018-12-06 13:03:26 Re: \gexec \watch
Previous Message Alvaro Herrera 2018-12-06 12:51:19 Re: \gexec \watch