explain_summary_examples.out.txt

text/plain

Filename: explain_summary_examples.out.txt
Type: text/plain
Part: 0
Message: Re: Reporting planning time with EXPLAIN
postgres=# explain select * from pg_class c, pg_type t where c.reltype = t.oid;
                                QUERY PLAN                                
--------------------------------------------------------------------------
 Hash Join  (cost=17.15..35.77 rows=321 width=511)
   Hash Cond: (c.reltype = t.oid)
   ->  Seq Scan on pg_class c  (cost=0.00..14.21 rows=321 width=259)
   ->  Hash  (cost=12.62..12.62 rows=362 width=256)
         ->  Seq Scan on pg_type t  (cost=0.00..12.62 rows=362 width=256)
(5 rows)

postgres=# explain (summary on) select * from pg_class c, pg_type t where c.reltype = t.oid;
                                QUERY PLAN                                
--------------------------------------------------------------------------
 Hash Join  (cost=17.15..35.77 rows=321 width=511)
   Hash Cond: (c.reltype = t.oid)
   ->  Seq Scan on pg_class c  (cost=0.00..14.21 rows=321 width=259)
   ->  Hash  (cost=12.62..12.62 rows=362 width=256)
         ->  Seq Scan on pg_type t  (cost=0.00..12.62 rows=362 width=256)
 Planning time: 0.326 ms
(6 rows)

postgres=# explain (summary off) select * from pg_class c, pg_type t where c.reltype = t.oid;
                                QUERY PLAN                                
--------------------------------------------------------------------------
 Hash Join  (cost=17.15..35.77 rows=321 width=511)
   Hash Cond: (c.reltype = t.oid)
   ->  Seq Scan on pg_class c  (cost=0.00..14.21 rows=321 width=259)
   ->  Hash  (cost=12.62..12.62 rows=362 width=256)
         ->  Seq Scan on pg_type t  (cost=0.00..12.62 rows=362 width=256)
(5 rows)

postgres=# explain analyze select * from pg_class c, pg_type t where c.reltype = t.oid;
                                                      QUERY PLAN                                                      
----------------------------------------------------------------------------------------------------------------------
 Hash Join  (cost=17.15..35.77 rows=321 width=511) (actual time=0.905..1.357 rows=198 loops=1)
   Hash Cond: (c.reltype = t.oid)
   ->  Seq Scan on pg_class c  (cost=0.00..14.21 rows=321 width=259) (actual time=0.010..0.066 rows=321 loops=1)
   ->  Hash  (cost=12.62..12.62 rows=362 width=256) (actual time=0.829..0.829 rows=362 loops=1)
         Buckets: 1024  Batches: 1  Memory Usage: 74kB
         ->  Seq Scan on pg_type t  (cost=0.00..12.62 rows=362 width=256) (actual time=0.007..0.425 rows=362 loops=1)
 Planning time: 0.328 ms
 Execution time: 1.510 ms
(8 rows)

postgres=# explain (summary on, analyze on) select * from pg_class c, pg_type t where c.reltype = t.oid;
                                                      QUERY PLAN                                                      
----------------------------------------------------------------------------------------------------------------------
 Hash Join  (cost=17.15..35.77 rows=321 width=511) (actual time=0.781..1.224 rows=198 loops=1)
   Hash Cond: (c.reltype = t.oid)
   ->  Seq Scan on pg_class c  (cost=0.00..14.21 rows=321 width=259) (actual time=0.009..0.061 rows=321 loops=1)
   ->  Hash  (cost=12.62..12.62 rows=362 width=256) (actual time=0.744..0.744 rows=362 loops=1)
         Buckets: 1024  Batches: 1  Memory Usage: 74kB
         ->  Seq Scan on pg_type t  (cost=0.00..12.62 rows=362 width=256) (actual time=0.007..0.358 rows=362 loops=1)
 Planning time: 0.333 ms
 Execution time: 1.360 ms
(8 rows)

postgres=# explain (summary off, analyze on) select * from pg_class c, pg_type t where c.reltype = t.oid;
                                                      QUERY PLAN                                                      
----------------------------------------------------------------------------------------------------------------------
 Hash Join  (cost=17.15..35.77 rows=321 width=511) (actual time=0.783..1.221 rows=198 loops=1)
   Hash Cond: (c.reltype = t.oid)
   ->  Seq Scan on pg_class c  (cost=0.00..14.21 rows=321 width=259) (actual time=0.009..0.059 rows=321 loops=1)
   ->  Hash  (cost=12.62..12.62 rows=362 width=256) (actual time=0.745..0.745 rows=362 loops=1)
         Buckets: 1024  Batches: 1  Memory Usage: 74kB
         ->  Seq Scan on pg_type t  (cost=0.00..12.62 rows=362 width=256) (actual time=0.007..0.358 rows=362 loops=1)
(6 rows)

postgres=# prepare somestmt as select count(*) from t1 where a > 100;
PREPARE
postgres=# explain (summary on) execute somestmt;
                        QUERY PLAN                         
-----------------------------------------------------------
 Aggregate  (cost=40.13..40.14 rows=1 width=8)
   ->  Seq Scan on t1  (cost=0.00..38.25 rows=753 width=0)
         Filter: (a > 100)
 Planning time: 0.245 ms
(4 rows)

postgres=# explain (summary on) execute somestmt;
                        QUERY PLAN                         
-----------------------------------------------------------
 Aggregate  (cost=40.13..40.14 rows=1 width=8)
   ->  Seq Scan on t1  (cost=0.00..38.25 rows=753 width=0)
         Filter: (a > 100)
 Planning time: 0.012 ms
(4 rows)

postgres=# alter table t1 add c;
ERROR:  syntax error at or near ";"
LINE 1: alter table t1 add c;
                            ^
postgres=# alter table t1 add c int;
ALTER TABLE
postgres=# explain (summary on) execute somestmt;
                        QUERY PLAN                         
-----------------------------------------------------------
 Aggregate  (cost=37.20..37.21 rows=1 width=8)
   ->  Seq Scan on t1  (cost=0.00..35.50 rows=680 width=0)
         Filter: (a > 100)
 Planning time: 0.265 ms
(4 rows)

postgres=# explain (summary on) execute somestmt;
                        QUERY PLAN                         
-----------------------------------------------------------
 Aggregate  (cost=37.20..37.21 rows=1 width=8)
   ->  Seq Scan on t1  (cost=0.00..35.50 rows=680 width=0)
         Filter: (a > 100)
 Planning time: 0.013 ms
(4 rows)