Display individual query in pg_stat_activity
От | Drouvot, Bertrand |
---|---|
Тема | Display individual query in pg_stat_activity |
Дата | |
Msg-id | 030a4123-550a-9dc1-d326-3cd5c46bcc59@amazon.com обсуждение исходный текст |
Ответы |
Re: Display individual query in pg_stat_activity
|
Список | pgsql-hackers |
Hi hackers,
I've attached a patch to display individual query in the pg_stat_activity query field when multiple SQL statements are currently displayed.
Motivation:
When multiple statements are displayed then we don’t know which one is currently running.
For example:
psql -c "select pg_sleep(10);select pg_sleep(20);" is currently displayed as:
Technical context and proposal:
There is 2 points in this patch:
So that we could see for example:
Another example: parallel worker being triggered while executing a function:
Regards,
Bertrand
I've attached a patch to display individual query in the pg_stat_activity query field when multiple SQL statements are currently displayed.
Motivation:
When multiple statements are displayed then we don’t know which one is currently running.
For example:
psql -c "select pg_sleep(10);select pg_sleep(20);" is currently displayed as:
postgres=# select backend_type,query from pg_stat_activity; backend_type | query ------------------------------+-------------------------------------------------- client backend | select pg_sleep(10);select pg_sleep(20);Showing which statement is currently being executed would be more helpful.
Technical context and proposal:
There is 2 points in this patch:
- modifying the current behavior in “exec_simple_query”
- modifying the current behavior in “ExecInitParallelPlan”
So that we could see for example:
backend_type | query ------------------------------+-------------------------------------------------- client backend | select pg_sleep(10);and then
backend_type | query ------------------------------+-------------------------------------------------- client backend | select pg_sleep(20);instead of the multiple sql statement described in the “motivation” section.
Another example: parallel worker being triggered while executing a function:
create or replace function test() returns void as $$select count() as "first" from foo;select pg_sleep(10);select count() as "second" from foo;select pg_sleep(11);select pg_sleep(10) $$ language sql;We currently see:
backend_type | query ------------------------------+-------------------------------------------------------------------------------------------------------------------------------------- client backend | select test(); parallel worker | select count(*) as "first" from foo;select pg_sleep(10);select count(*) as "second" from foo;select pg_sleep(11);select pg_sleep(10)+ | parallel worker | select count(*) as "first" from foo;select pg_sleep(10);select count(*) as "second" from foo;select pg_sleep(11);select pg_sleep(10)+ |while the attached patch would provide:
backend_type | query [217/1938] ------------------------------+-------------------------------------------------- client backend | select test(); parallel worker | select count(*) as "first" from foo; parallel worker | select count(*) as "first" from foo;and then:
backend_type | query ------------------------------+-------------------------------------------------- client backend | select test(); parallel worker | select count(*) as "second" from foo; parallel worker | select count(*) as "second" from foo;I will add this patch to the next commitfest. I look forward to your feedback about the idea and/or implementation.
Regards,
Bertrand
Вложения
В списке pgsql-hackers по дате отправления: