Re: psql \watch versus \timing

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql \watch versus \timing
Date: 2014-09-01 13:41:45
Message-ID: CAB7nPqSR4pjGcnzAhPCruySYzHMFsaqw5eFuAZ4wc8+DXEMcBQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Aug 29, 2014 at 6:33 PM, Heikki Linnakangas
<hlinnakangas(at)vmware(dot)com> wrote:
> On 08/28/2014 02:46 PM, Fujii Masao wrote:
>>
>> On Tue, Aug 26, 2014 at 4:55 AM, Heikki Linnakangas
>> <hlinnakangas(at)vmware(dot)com> wrote:
>>>
>>> On 08/25/2014 10:48 PM, Heikki Linnakangas wrote:
>>>>
>>>> Actually, perhaps it would be better to just copy-paste PSQLexec, and
>>>> modify the copy to suite \watch's needs. (PSQLexecWatch?
>>>> SendWatchQuery?). PSQLexec doesn't do much, and there isn't very much
>>>> overlap between what \watch wants and what other PSQLexec callers want.
>>>> \watch wants timing output, others don't. \watch doesn't want
>>>> transaction handling.
>>
>>
>> Agreed. Attached is the revised version of the patch. I implemented
>> PSQLexecWatch() which sends the query, prints the results and outputs
>> the query execution time (if \timing is enabled).
>>
>> This patch was marked as ready for committer, but since I revised
>> the code very much, I marked this as needs review again.
>
>
> This comment:
>
>> ... We use PSQLexecWatch,
>> ! * which is kind of cheating, but SendQuery doesn't let us
>> suppress
>> ! * autocommit behavior.
>
>
> is a bit strange now. PSQLexecWatch isn't cheating like reusing PSQLexec
> was; it's whole purpose is to run \watch queries.
>
>> /*
>> * Set up cancellation of 'watch' via SIGINT. We redo
>> this each time
>> * through the loop since it's conceivable something
>> inside PSQLexec
>> * could change sigint_interrupt_jmp.
>> */
>
>
> This should now say "PSQLexecWatch".
>
> Other than that, looks good to me.

I just tested the patch and this feature works as expected if timing
is on and it displays the individual run time of each query kicked by
\watch. Note that --echo-hidden does not display the query run during
each loop and that this is contrary to the behavior in HEAD so it
breaks backward compatibility, but are there really people relying in
the existing behavior?
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2014-09-01 13:43:40 Re: Concurrently option for reindexdb
Previous Message Andres Freund 2014-09-01 13:25:14 Re: PL/pgSQL 2