| -- start_matchsubs |
| -- m/^LOG.*\"Falling/ |
| -- s/^LOG.*\"Falling/\"Falling/ |
| -- end_matchsubs |
| CREATE SCHEMA auto_explain_test; |
| CREATE TABLE auto_explain_test.t1(a int); |
| NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Apache Cloudberry data distribution key for this table. |
| HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. |
| INSERT INTO auto_explain_test.t1 VALUES(generate_series(0, 1000)); |
| ANALYZE auto_explain_test.t1; |
| CREATE TABLE auto_explain_test.t2(b int); |
| NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'b' as the Apache Cloudberry data distribution key for this table. |
| HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. |
| INSERT INTO auto_explain_test.t2 VALUES(generate_series(0, 1000)); |
| ANALYZE auto_explain_test.t2; |
| SET enable_nestloop = ON; |
| SET CLIENT_MIN_MESSAGES = LOG; |
| LOAD 'auto_explain'; |
| LOG: statement: LOAD 'auto_explain'; |
| SET auto_explain.log_analyze = TRUE; |
| LOG: statement: SET auto_explain.log_analyze = TRUE; |
| SET auto_explain.log_min_duration = 0; |
| LOG: statement: SET auto_explain.log_min_duration = 0; |
| SET auto_explain.log_buffers = FALSE; |
| LOG: statement: SET auto_explain.log_buffers = FALSE; |
| SET auto_explain.log_triggers = TRUE; |
| LOG: statement: SET auto_explain.log_triggers = TRUE; |
| SET auto_explain.log_nested_statements = FALSE; |
| LOG: statement: SET auto_explain.log_nested_statements = FALSE; |
| SET auto_explain.log_timing = FALSE; |
| LOG: statement: SET auto_explain.log_timing = FALSE; |
| SET auto_explain.log_verbose = FALSE; |
| LOG: statement: SET auto_explain.log_verbose = FALSE; |
| SELECT relname FROM pg_class WHERE relname='pg_class'; |
| LOG: statement: SELECT relname FROM pg_class WHERE relname='pg_class'; |
| LOG: duration: 0.173 ms plan: |
| Query Text: SELECT relname FROM pg_class WHERE relname='pg_class'; |
| Index Only Scan using pg_class_relname_nsp_index on pg_class (cost=0.15..4.17 rows=1 width=64) (actual rows=1 loops=1) |
| Index Cond: (relname = 'pg_class'::name) |
| Heap Fetches: 1 |
| Optimizer: Postgres-based planner |
| (slice0) Executor memory: 105K bytes. |
| Memory used: 128000kB |
| relname |
| ---------- |
| pg_class |
| (1 row) |
| |
| SELECT count(*) FROM auto_explain_test.t1, auto_explain_test.t2; |
| LOG: statement: SELECT count(*) FROM auto_explain_test.t1, auto_explain_test.t2; |
| LOG: duration: 165.358 ms plan: |
| Query Text: SELECT count(*) FROM auto_explain_test.t1, auto_explain_test.t2; |
| Finalize Aggregate (cost=35148.64..35148.65 rows=1 width=8) (actual rows=1 loops=1) |
| -> Gather Motion 3:1 (slice1; segments: 3) (cost=35148.61..35148.64 rows=1 width=8) (actual rows=3 loops=1) |
| -> Partial Aggregate (cost=35148.61..35148.62 rows=1 width=8) (actual rows=1 loops=1) |
| -> Nested Loop (cost=0.00..32643.60 rows=334001 width=0) (actual rows=340340 loops=1) |
| -> Seq Scan on t1 (cost=0.00..13.01 rows=334 width=0) (actual rows=340 loops=1) |
| -> Materialize (cost=0.00..68.06 rows=1001 width=0) (actual rows=1001 loops=340) |
| -> Broadcast Motion 3:3 (slice2; segments: 3) (cost=0.00..53.05 rows=1001 width=0) (actual rows=1001 loops=1) |
| -> Seq Scan on t2 (cost=0.00..13.01 rows=334 width=0) (actual rows=340 loops=1) |
| Optimizer: Postgres-based planner |
| (slice0) Executor memory: 131K bytes. |
| (slice1) Executor memory: 152K bytes avg x 3 workers, 152K bytes max (seg0). |
| (slice2) Executor memory: 42K bytes avg x 3 workers, 42K bytes max (seg0). |
| Memory used: 128000kB |
| count |
| --------- |
| 1002001 |
| (1 row) |
| |
| SET auto_explain.log_min_duration = 1000; |
| LOG: statement: SET auto_explain.log_min_duration = 1000; |
| SET auto_explain.log_triggers = FALSE; |
| LOG: statement: SET auto_explain.log_triggers = FALSE; |
| SET auto_explain.log_verbose = TRUE; |
| LOG: statement: SET auto_explain.log_verbose = TRUE; |
| -- this select should not dump execution plan |
| SELECT relname FROM pg_class WHERE relname='pg_class'; |
| LOG: statement: SELECT relname FROM pg_class WHERE relname='pg_class'; |
| relname |
| ---------- |
| pg_class |
| (1 row) |
| |
| -- this select should also dump plan, since it takes too much time to run |
| SELECT count(*), pg_sleep(1) FROM auto_explain_test.t1, auto_explain_test.t2; |
| LOG: statement: SELECT count(*), pg_sleep(1) FROM auto_explain_test.t1, auto_explain_test.t2; |
| LOG: duration: 208.523 ms plan: |
| Query Text: SELECT count(*), pg_sleep(1) FROM auto_explain_test.t1, auto_explain_test.t2; |
| Finalize Aggregate (cost=35148.64..35148.65 rows=1 width=8) (actual rows=1 loops=1) |
| Output: count(*), pg_sleep('1'::double precision) |
| -> Gather Motion 3:1 (slice1; segments: 3) (cost=35148.61..35148.64 rows=1 width=8) (actual rows=3 loops=1) |
| Output: (PARTIAL count(*)) |
| -> Partial Aggregate (cost=35148.61..35148.62 rows=1 width=8) (actual rows=1 loops=1) |
| Output: PARTIAL count(*) |
| -> Nested Loop (cost=0.00..32643.60 rows=334001 width=0) (actual rows=340340 loops=1) |
| -> Seq Scan on auto_explain_test.t1 (cost=0.00..13.01 rows=334 width=0) (actual rows=340 loops=1) |
| Output: t1.a |
| -> Materialize (cost=0.00..68.06 rows=1001 width=0) (actual rows=1001 loops=340) |
| work_mem: 142kB Segments: 3 Max: 48kB (segment 0) Workfile: (0 spilling) |
| -> Broadcast Motion 3:3 (slice2; segments: 3) (cost=0.00..53.05 rows=1001 width=0) (actual rows=1001 loops=1) |
| -> Seq Scan on auto_explain_test.t2 (cost=0.00..13.01 rows=334 width=0) (actual rows=340 loops=1) |
| Optimizer: Postgres-based planner |
| Settings: enable_nestloop = 'on', optimizer = 'off' |
| (slice0) Executor memory: 131K bytes. |
| (slice1) Executor memory: 152K bytes avg x 3 workers, 152K bytes max (seg0). |
| (slice2) Executor memory: 42K bytes avg x 3 workers, 42K bytes max (seg0). |
| Memory used: 128000kB |
| count | pg_sleep |
| ---------+---------- |
| 1002001 | |
| (1 row) |
| |
| -- clean jobs |
| DROP TABLE auto_explain_test.t1; |
| LOG: statement: DROP TABLE auto_explain_test.t1; |
| DROP TABLE auto_explain_test.t2; |
| LOG: statement: DROP TABLE auto_explain_test.t2; |
| DROP SCHEMA auto_explain_test; |
| LOG: statement: DROP SCHEMA auto_explain_test; |