Prevent psql \watch from running queries that return no rows

Поиск
Список
Период
Сортировка
От Greg Sabino Mullane
Тема Prevent psql \watch from running queries that return no rows
Дата
Msg-id CAKAnmmKStATuddYxP71L+p0DHtp9Rvjze3XRoy0Dyw67VQ45UA@mail.gmail.com
обсуждение исходный текст
Ответы Re: Prevent psql \watch from running queries that return no rows  (Michael Paquier <michael@paquier.xyz>)
Список pgsql-hackers
Attached is a patch to allow a new behavior for the \watch command in psql. When enabled, this instructs \watch to stop running once the query returns zero rows. The use case is the scenario in which you are watching the output of something long-running such as pg_stat_progress_create_index, but once it finishes you don't need thousands of runs showing empty rows from the view.

This adds a new argument "zero" to the existing i=SEC and c=N arguments

Notes:

* Not completely convinced of the name "zero" (better than "stop_when_no_rows_returned"). Considered adding a new x=y argument, or overloading c (c=-1) but neither seemed very intuitive. On the other hand, it's tempting to stick to a single method moving forward, although this is a boolean option not a x=y one like the other two.

* Did not update help.c on purpose - no need to make \watch span two lines there.

* Considered leaving early (e.g. don't display the last empty result) but seemed better to show the final empty result as an explicit confirmation as to why it stopped.

* Quick way to test:
select * from pg_stat_activity where backend_start > now() - '20 seconds'::interval;
\watch zero

Cheers,
Greg

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Tristan Partin"
Дата:
Сообщение: Re: [PATCH] Missing dep on Catalog.pm in meson rules
Следующее
От: James Coleman
Дата:
Сообщение: Re: RFC: Logging plan of the running query