From: | Pavel Luzanov <p(dot)luzanov(at)postgrespro(dot)ru> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Ron <ronljohnsonjr(at)gmail(dot)com> |
Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: EXPLAIN with anonymous DO block? |
Date: | 2021-07-01 16:48:11 |
Message-ID: | 5895ad95-20d0-2ee5-a0d1-9a2d77e6edfb@postgrespro.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Good day!
>> There's a query inside a DO block which -- because it's parameterized -- I'd
>> rather analyze while it's in the FOR loop of a DO block, instead of pulling
>> it out and hard-coding the parameters.
>> Is this possible?
> No.
Why not to use auto_explain module?
postgres=# LOAD 'auto_explain';
LOAD
postgres=# SET auto_explain.log_min_duration = 0;
SET
postgres=# SET auto_explain.log_nested_statements = on;
SET
postgres=# SET auto_explain.log_analyze = on;
SET
postgres=# SET auto_explain.log_level = 'NOTICE';
SET
postgres=# DO $$BEGIN FOR i IN 112 .. 113 LOOP PERFORM * FROM pg_class
WHERE oid = i::oid; END LOOP; END;$$;
NOTICE: duration: 0.013 ms plan:
Query Text: SELECT * FROM pg_class WHERE oid = i::oid
Index Scan using pg_class_oid_index on pg_class (cost=0.27..8.29 rows=1
width=265) (actual time=0.009..0.011 rows=1 loops=1)
Index Cond: (oid = '112'::oid)
NOTICE: duration: 0.016 ms plan:
Query Text: SELECT * FROM pg_class WHERE oid = i::oid
Index Scan using pg_class_oid_index on pg_class (cost=0.27..8.29 rows=1
width=265) (actual time=0.008..0.009 rows=1 loops=1)
Index Cond: (oid = '113'::oid)
DO
Pavel Luzanov
Postgres Professional: https://postgrespro.com
The Russian Postgres Company
From | Date | Subject | |
---|---|---|---|
Next Message | W.P. | 2021-07-01 19:56:17 | Re: Damaged (during upgrade?) table, how to repair? |
Previous Message | David G. Johnston | 2021-07-01 16:28:54 | Re: EXPLAIN with anonymous DO block? |