OSDN Git Service

Follow new shared memory request convention since PG15
[pgstoreplans/pg_store_plans.git] / makeplanfile.sql
index bf25cfc..72f6e88 100644 (file)
@@ -96,7 +96,7 @@ set work_mem = '128kB';
 explain (analyze on, buffers on, verbose on, format :format)
    select b from tt1 group by b;
 set work_mem = '1MB';
-\echo ###### SetOp intersect, SbuqueryScan
+\echo ###### SetOp intersect, SubqueryScan
 explain (analyze on, buffers on, verbose on, format :format)
    select a from tt1 intersect select b from tt2 order by a;
 \echo ###### Sorted SetOp, Sort on Disk
@@ -189,6 +189,11 @@ explain (analyze on, buffers on, verbose on, format :format)
     PASSING BY REF '<towns><town><name>Toronto</name></town><town><name>Ottawa</name></town></towns>'
         COLUMNS name text);
 
+\echo ###### Incremental Sort
+explain (analyze on, buffers on, verbose on, format :format)
+       WITH x AS (SELECT i/100 + 1 AS a, i + 1 AS b FROM generate_series(0, 999) i)
+         SELECT * FROM (SELECT * FROM x ORDER BY a) s ORDER BY a, b LIMIT 31;
+
 -- Named Tuplestore Scan -- requires auto_explain
 DROP TABLE IF EXISTS e1 CASCADE;
 CREATE TABLE e1 (a int, b int);
@@ -201,9 +206,10 @@ BEGIN
   RETURN NEW;
 END;
 $$ LANGUAGE plpgsql;
-CREATE TRIGGER e1_t1 AFTER INSERT OR UPDATE ON e1
- REFERENCING NEW TABLE AS post OLD TABLE AS pre
+CREATE TRIGGER e1_t1 AFTER INSERT ON e1
+ REFERENCING NEW TABLE AS post
  FOR EACH ROW EXECUTE PROCEDURE e1_t1();
+
 INSERT INTO e1 VALUES (1, 1);
 
 load 'auto_explain';
@@ -217,12 +223,15 @@ set auto_explain.log_nested_statements to true;
 set client_min_messages to LOG;
 set log_min_messages to FATAL; -- Inhibit LOG by auto_explain
 \echo ###### Named Tuplestore Scan
+CREATE TRIGGER e1_t2 AFTER UPDATE ON e1
+ REFERENCING NEW TABLE AS post OLD TABLE AS pre
+ FOR EACH ROW EXECUTE PROCEDURE e1_t1();
 UPDATE e1 SET a = a + 1;
 set client_min_messages to DEFAULT;
 set log_min_messages to DEFAULT;
 set auto_explain.log_min_duration to -1;
 
-\echo ###### Parallel
+-- ###### Parallel
 drop table if exists lt1;
 create table lt1 (a int, b text);
 alter table lt1 alter column b set storage plain;
@@ -233,10 +242,14 @@ set parallel_setup_cost to 0;
 set min_parallel_table_scan_size to 0;
 set min_parallel_index_scan_size to 0;
 
-\echo ###### Gather
+\echo ###### Parallel Seq Scan
 explain (analyze on, buffers on, verbose on, format :format)
    SELECT * FROM lt1;
 
+\echo ###### Parallel Index Scan
+explain (analyze on, buffers on, verbose on, format :format)
+   SELECT * FROM tt1 where a < 100;
+
 \echo ###### Gather Merge
 explain (analyze on, buffers on, verbose on, format :format)
    SELECT a FROM tt1 ORDER BY a;