| From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> | 
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> | 
| Cc: | Thom Brown <thom(at)linux(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Dimitri Fontaine <dimitri(at)2ndquadrant(dot)fr>, Simon Riggs <simon(at)2ndquadrant(dot)com> | 
| Subject: | VIP: explain of running query | 
| Date: | 2014-09-05 19:54:25 | 
| Message-ID: | CAFj8pRAXcS9B8ABgiM-zauVgGqDhPZOaRz5YSp1_Nhv9HP8nKw@mail.gmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
Hi
I am sending a prototype with basic implementation with explain of running
query specified by pid.
It can show more than the execution plan. There is a examples of full query
text and running completion tag.
This patch is in early stage - I know, so there is one race condition.
I hoped so I can use new shm_mq API, but it is not prepared for usage where
receiver and sender are mutable.
How it works:
postgres=# select pg_cmdstatus(pid,1) from pg_stat_activity where pid <>
pg_backend_pid();
pg_cmdstatus
-------------------------------------------------------------------------------
 Query Text: select * from pg_class, pg_attribute limit 4000000;
 Limit  (cost=0.00..8795.58 rows=697380 width=403)
   ->  Nested Loop  (cost=0.00..8795.58 rows=697380 width=403)
         ->  Seq Scan on pg_attribute  (cost=0.00..66.64 rows=2364
width=203)
         ->  Materialize  (cost=0.00..12.42 rows=295 width=200)
               ->  Seq Scan on pg_class  (cost=0.00..10.95 rows=295
width=200)
(6 rows)
postgres=# select pg_cmdstatus(pid,2) from pg_stat_activity where pid <>
pg_backend_pid();
                    pg_cmdstatus
-----------------------------------------------------
 select * from pg_class, pg_attribute limit 4000000;
(1 row)
postgres=# select pg_cmdstatus(pid,3) from pg_stat_activity where pid <>
pg_backend_pid();
 pg_cmdstatus
---------------
 SELECT 144427
(1 row)
postgres=# select pg_cmdstatus(pid,3) from pg_stat_activity where pid <>
pg_backend_pid();
 pg_cmdstatus
---------------
 SELECT 209742
(1 row)
postgres=# select pg_cmdstatus(pid,3) from pg_stat_activity where pid <>
pg_backend_pid();
 pg_cmdstatus
---------------
 SELECT 288472
(1 row)
In future a function can be replaced by statement EXPLAIN pid WITH
autocomplete - It can show a subset of EXPLAIN ANALYZE -- but it needs a
some parametrization of executor environment.
First discuss to this topic was year ago
Regards
Pavel
| Attachment | Content-Type | Size | 
|---|---|---|
| explain-pid-1.patch | text/x-patch | 15.4 KB | 
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Merlin Moncure | 2014-09-05 20:07:13 | Re: Allowing implicit 'text' -> xml|json|jsonb (was: PL/pgSQL 2) | 
| Previous Message | Tomas Vondra | 2014-09-05 19:23:58 | Re: bad estimation together with large work_mem generates terrible slow hash joins |