diff --git a/src/test/regress/expected/explain_format.out b/src/test/regress/expected/explain_format.out index c81e75edd84107a6d984a9b0ed7a98a1ce7f00dc..b85738abfcac8ccac9264b294df147269cba9e27 100644 --- a/src/test/regress/expected/explain_format.out +++ b/src/test/regress/expected/explain_format.out @@ -20,7 +20,8 @@ CREATE TABLE boxes(id int PRIMARY KEY, apple_id int REFERENCES apples(id), locat NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "boxes_pkey" for table "boxes" WARNING: Referential integrity (FOREIGN KEY) constraints are not supported in Greenplum Database, will not be enforced. WARNING: Referential integrity (FOREIGN KEY) constraints are not supported in Greenplum Database, will not be enforced. ---- Check Explain Text output +--- Check Explain Text format output +-- explain_processing_off EXPLAIN SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; QUERY PLAN ------------------------------------------------------------------------------------------------------------------ @@ -41,7 +42,8 @@ EXPLAIN SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT Optimizer: legacy query optimizer (15 rows) ---- Check Explain Analyze Text output +-- explain_processing_on +--- Check Explain Analyze Text output that include the slices information -- explain_processing_off EXPLAIN (ANALYZE) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; QUERY PLAN @@ -70,3 +72,1068 @@ EXPLAIN (ANALYZE) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.appl (21 rows) -- explain_processing_on +-- YAML Required replaces for costs and time changes +-- start_matchsubs +-- m/ Loops: \d+ / +-- s/ Loops: \d+\s+/ Loops: # / +-- m/ Cost: \d+\.\d+ / +-- s/ Cost: \d+\.\d+\s+/ Cost: ###.## / +-- m/ Rows: \d+ / +-- s/ Rows: \d+\s+/ Rows: ##### / +-- m/ Plan Width: \d+ / +-- s/ Plan Width: \d+\s+/ Plan Width: ## / +-- m/ Time: \d+\.\d+ / +-- s/ Time: \d+\.\d+\s+/ Time: ##.### / +-- m/Total Runtime: \d+\.\d+/ +-- s/Total Runtime: \d+\.\d+/Total Runtime: ##.###/ +-- m/Segments: \d+\s+/ +-- s/Segments: \d+\s+/Segments: #/ +-- m/PQO version \d+\.\d+\.\d+"\s+/ +-- s/PQO version \d+\.\d+\.\d+"\s+/PQO version ##.##.##"/ +-- end_matchsubs +-- Check Explain YAML output +EXPLAIN (FORMAT YAML) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; + QUERY PLAN +--------------------------------------------------------- + - Plan: + + Node Type: "Gather Motion" + + Senders: 3 + + Receivers: 1 + + Slice: 3 + + Segments: 3 + + Gang Type: "primary reader" + + Startup Cost: 2432.00 + + Total Cost: 8569.25 + + Plan Rows: 77900 + + Plan Width: 84 + + Plans: + + - Node Type: "Hash Join" + + Parent Relationship: "Outer" + + Slice: 3 + + Segments: 3 + + Gang Type: "primary reader" + + Join Type: "Left" + + Startup Cost: 2432.00 + + Total Cost: 8569.25 + + Plan Rows: 77900 + + Plan Width: 84 + + Hash Cond: "boxes.location_id = locations.id" + + Plans: + + - Node Type: "Redistribute Motion" + + Senders: 3 + + Receivers: 3 + + Parent Relationship: "Outer" + + Slice: 2 + + Segments: 3 + + Gang Type: "primary reader" + + Startup Cost: 1216.00 + + Total Cost: 6282.12 + + Plan Rows: 77900 + + Plan Width: 48 + + Hash Key: "boxes.location_id" + + Plans: + + - Node Type: "Hash Join" + + Parent Relationship: "Outer" + + Slice: 2 + + Segments: 3 + + Gang Type: "primary reader" + + Join Type: "Left" + + Startup Cost: 1216.00 + + Total Cost: 4724.12 + + Plan Rows: 77900 + + Plan Width: 48 + + Hash Cond: "boxes.apple_id = apples.id"+ + Plans: + + - Node Type: "Redistribute Motion" + + Senders: 3 + + Receivers: 3 + + Parent Relationship: "Outer" + + Slice: 1 + + Segments: 3 + + Gang Type: "primary reader" + + Startup Cost: 0.00 + + Total Cost: 2437.00 + + Plan Rows: 77900 + + Plan Width: 12 + + Hash Key: "boxes.apple_id" + + Plans: + + - Node Type: "Seq Scan" + + Parent Relationship: "Outer" + + Slice: 1 + + Segments: 3 + + Gang Type: "primary reader" + + Relation Name: "boxes" + + Alias: "boxes" + + Startup Cost: 0.00 + + Total Cost: 879.00 + + Plan Rows: 77900 + + Plan Width: 12 + + - Node Type: "Hash" + + Parent Relationship: "Inner" + + Slice: 2 + + Segments: 3 + + Gang Type: "primary reader" + + Startup Cost: 596.00 + + Total Cost: 596.00 + + Plan Rows: 49600 + + Plan Width: 36 + + Plans: + + - Node Type: "Seq Scan" + + Parent Relationship: "Outer" + + Slice: 2 + + Segments: 3 + + Gang Type: "primary reader" + + Relation Name: "apples" + + Alias: "apples" + + Startup Cost: 0.00 + + Total Cost: 596.00 + + Plan Rows: 49600 + + Plan Width: 36 + + - Node Type: "Hash" + + Parent Relationship: "Inner" + + Slice: 3 + + Segments: 3 + + Gang Type: "primary reader" + + Startup Cost: 596.00 + + Total Cost: 596.00 + + Plan Rows: 49600 + + Plan Width: 36 + + Plans: + + - Node Type: "Seq Scan" + + Parent Relationship: "Outer" + + Slice: 3 + + Segments: 10 + + Gang Type: "primary reader" + + Relation Name: "locations" + + Alias: "locations" + + Startup Cost: 0.00 + + Total Cost: 596.00 + + Plan Rows: 49600 + + Plan Width: 36 + + Settings: + + Optimizer: "legacy query optimizer" +(1 row) + +--- Check Explain Analyze YAML output that include the slices information +-- explain_processing_off +EXPLAIN (ANALYZE, FORMAT YAML) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; + QUERY PLAN +--------------------------------------------------------- + - Plan: + + Node Type: "Gather Motion" + + Senders: 3 + + Receivers: 1 + + Slice: 3 + + Segments: 3 + + Gang Type: "primary reader" + + Startup Cost: 2432.00 + + Total Cost: 8569.25 + + Plan Rows: 77901 + + Plan Width: 100 + + Actual Startup Time: 1.842 + + Actual Total Time: 1.842 + + Actual Rows: 50 + + Actual Loops: 3 + + Plans: + + - Node Type: "Hash Join" + + Parent Relationship: "Outer" + + Slice: 3 + + Segments: 3 + + Gang Type: "primary reader" + + Join Type: "Left" + + Startup Cost: 2432.00 + + Total Cost: 8569.25 + + Plan Rows: 900 + + Plan Width: 84 + + Actual Startup Time: 0.000 + + Actual Total Time: 0.000 + + Actual Rows: 0 + + Actual Loops: 0 + + Hash Cond: "boxes.location_id = locations.id" + + Plans: + + - Node Type: "Redistribute Motion" + + Senders: 3 + + Receivers: 3 + + Parent Relationship: "Outer" + + Slice: 2 + + Segments: 3 + + Gang Type: "primary reader" + + Startup Cost: 1216.00 + + Total Cost: 6282.12 + + Plan Rows: 77900 + + Plan Width: 48 + + Actual Startup Time: 0.000 + + Actual Total Time: 0.000 + + Actual Rows: 0 + + Actual Loops: 0 + + Hash Key: "boxes.location_id" + + Plans: + + - Node Type: "Hash Join" + + Parent Relationship: "Outer" + + Slice: 2 + + Segments: 3 + + Gang Type: "primary reader" + + Join Type: "Left" + + Startup Cost: 1216.00 + + Total Cost: 4724.12 + + Plan Rows: 77900 + + Plan Width: 48 + + Actual Startup Time: 0.000 + + Actual Total Time: 0.000 + + Actual Rows: 0 + + Actual Loops: 0 + + Hash Cond: "boxes.apple_id = apples.id"+ + Plans: + + - Node Type: "Redistribute Motion" + + Senders: 3 + + Receivers: 3 + + Parent Relationship: "Outer" + + Slice: 1 + + Segments: 3 + + Gang Type: "primary reader" + + Startup Cost: 0.00 + + Total Cost: 2437.00 + + Plan Rows: 77900 + + Plan Width: 12 + + Actual Startup Time: 0.000 + + Actual Total Time: 0.000 + + Actual Rows: 0 + + Actual Loops: 0 + + Hash Key: "boxes.apple_id" + + Plans: + + - Node Type: "Seq Scan" + + Parent Relationship: "Outer" + + Slice: 1 + + Segments: 3 + + Gang Type: "primary reader" + + Relation Name: "boxes" + + Alias: "boxes" + + Startup Cost: 0.00 + + Total Cost: 879.00 + + Plan Rows: 77900 + + Plan Width: 12 + + Actual Startup Time: 0.000 + + Actual Total Time: 0.000 + + Actual Rows: 0 + + Actual Loops: 0 + + - Node Type: "Hash" + + Parent Relationship: "Inner" + + Slice: 2 + + Segments: 3 + + Gang Type: "primary reader" + + Startup Cost: 596.00 + + Total Cost: 596.00 + + Plan Rows: 49600 + + Plan Width: 36 + + Actual Startup Time: 0.000 + + Actual Total Time: 0.000 + + Actual Rows: 0 + + Actual Loops: 0 + + Plans: + + - Node Type: "Seq Scan" + + Parent Relationship: "Outer" + + Slice: 2 + + Segments: 3 + + Gang Type: "primary reader" + + Relation Name: "apples" + + Alias: "apples" + + Startup Cost: 0.00 + + Total Cost: 596.00 + + Plan Rows: 49600 + + Plan Width: 36 + + Actual Startup Time: 0.000 + + Actual Total Time: 0.000 + + Actual Rows: 0 + + Actual Loops: 0 + + - Node Type: "Hash" + + Parent Relationship: "Inner" + + Slice: 3 + + Segments: 3 + + Gang Type: "primary reader" + + Startup Cost: 596.00 + + Total Cost: 596.00 + + Plan Rows: 49600 + + Plan Width: 36 + + Actual Startup Time: 0.000 + + Actual Total Time: 0.000 + + Actual Rows: 0 + + Actual Loops: 0 + + Plans: + + - Node Type: "Seq Scan" + + Parent Relationship: "Outer" + + Slice: 3 + + Segments: 10 + + Gang Type: "primary reader" + + Relation Name: "locations" + + Alias: "locations" + + Startup Cost: 0.00 + + Total Cost: 596.00 + + Plan Rows: 49600 + + Plan Width: 36 + + Actual Startup Time: 0.000 + + Actual Total Time: 0.000 + + Actual Rows: 0 + + Actual Loops: 0 + + Triggers: + + Statement statistics: + + Memory used: 128000 + + Settings: + + Optimizer: "legacy query optimizer" + + Total Runtime: 2.652 +(1 row) + +-- explain_processing_on +-- JSON Required replaces for costs and time changes +-- start_matchsubs +-- m/ Loops": \d+,?\s+/ +-- s/ Loops": \d+,?\s+/ Loops": #, / +-- m/ Cost": \d+\.\d+, / +-- s/ Cost": \d+\.\d+,\s+/ Cost": ###.##, / +-- m/ Rows": \d+, / +-- s/ Rows": \d+,\s+/ Rows": #####, / +-- m/"Plan Width": \d+,? / +-- s/"Plan Width": \d+,?\s+/"Plan Width": ##, / +-- m/ Time": \d+\.\d+, / +-- s/ Time": \d+\.\d+,\s+/ Time": ##.###, / +-- m/Total Runtime": \d+\.\d+,?\s+/ +-- s/Total Runtime": \d+\.\d+,?\s+/Total Runtime": ##.###,/ +-- m/"Memory used": \d+,?\s+/ +-- s/"Memory used": \d+,?\s+/"Memory used": ####,/ +-- m/"Segments": \d+,\s+/ +-- s/"Segments": \d+,\s+/"Segments": #,/ +-- end_matchsubs +-- explain_processing_off +-- Check Explain JSON output +EXPLAIN (FORMAT JSON) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; + QUERY PLAN +-------------------------------------------------------------- + [ + + { + + "Plan": { + + "Node Type": "Gather Motion", + + "Senders": 3, + + "Receivers": 1, + + "Slice": 3, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Startup Cost": 242.00, + + "Total Cost": 859.25, + + "Plan Rows": 7790, + + "Plan Width": 10, + + "Plans": [ + + { + + "Node Type": "Hash Join", + + "Parent Relationship": "Outer", + + "Slice": 3, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Join Type": "Left", + + "Startup Cost": 242.00, + + "Total Cost": 859.25, + + "Plan Rows": 7700, + + "Plan Width": 10, + + "Hash Cond": "boxes.location_id = locations.id", + + "Plans": [ + + { + + "Node Type": "Redistribute Motion", + + "Senders": 3, + + "Receivers": 3, + + "Parent Relationship": "Outer", + + "Slice": 2, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Startup Cost": 121.00, + + "Total Cost": 628.12, + + "Plan Rows": 7790, + + "Plan Width": 4, + + "Hash Key": "boxes.location_id", + + "Plans": [ + + { + + "Node Type": "Hash Join", + + "Parent Relationship": "Outer", + + "Slice": 2, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Join Type": "Left", + + "Startup Cost": 1216.00, + + "Total Cost": 4724.12, + + "Plan Rows": 77900, + + "Plan Width": 48, + + "Hash Cond": "boxes.apple_id = apples.id",+ + "Plans": [ + + { + + "Node Type": "Redistribute Motion", + + "Senders": 3, + + "Receivers": 3, + + "Parent Relationship": "Outer", + + "Slice": 1, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Startup Cost": 0.00, + + "Total Cost": 2437.00, + + "Plan Rows": 77900, + + "Plan Width": 12, + + "Hash Key": "boxes.apple_id", + + "Plans": [ + + { + + "Node Type": "Seq Scan", + + "Parent Relationship": "Outer", + + "Slice": 1, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Relation Name": "boxes", + + "Alias": "boxes", + + "Startup Cost": 0.00, + + "Total Cost": 879.00, + + "Plan Rows": 77900, + + "Plan Width": 12 + + } + + ] + + }, + + { + + "Node Type": "Hash", + + "Parent Relationship": "Inner", + + "Slice": 2, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Startup Cost": 596.00, + + "Total Cost": 596.00, + + "Plan Rows": 49600, + + "Plan Width": 36, + + "Plans": [ + + { + + "Node Type": "Seq Scan", + + "Parent Relationship": "Outer", + + "Slice": 2, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Relation Name": "apples", + + "Alias": "apples", + + "Startup Cost": 0.00, + + "Total Cost": 596.00, + + "Plan Rows": 49600, + + "Plan Width": 36 + + } + + ] + + } + + ] + + } + + ] + + }, + + { + + "Node Type": "Hash", + + "Parent Relationship": "Inner", + + "Slice": 3, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Startup Cost": 596.00, + + "Total Cost": 596.00, + + "Plan Rows": 49600, + + "Plan Width": 36, + + "Plans": [ + + { + + "Node Type": "Seq Scan", + + "Parent Relationship": "Outer", + + "Slice": 3, + + "Segments": 10, + + "Gang Type": "primary reader", + + "Relation Name": "locations", + + "Alias": "locations", + + "Startup Cost": 0.00, + + "Total Cost": 596.00, + + "Plan Rows": 49600, + + "Plan Width": 36 + + } + + ] + + } + + ] + + } + + ] + + }, + + "Settings": { + + "Optimizer": "legacy query optimizer" + + } + + } + + ] +(1 row) + +-- explain_processing_on +--- Check Explain Analyze JSON output that include the slices information +-- explain_processing_off +EXPLAIN (ANALYZE, FORMAT JSON) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; + QUERY PLAN +-------------------------------------------------------------- + [ + + { + + "Plan": { + + "Node Type": "Gather Motion", + + "Senders": 3, + + "Receivers": 1, + + "Slice": 3, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Startup Cost": 2432.00, + + "Total Cost": 8569.25, + + "Plan Rows": 77900, + + "Plan Width": 84, + + "Actual Startup Time": 5.415, + + "Actual Total Time": 5.415, + + "Actual Rows": 0, + + "Actual Loops": 1, + + "Plans": [ + + { + + "Node Type": "Hash Join", + + "Parent Relationship": "Outer", + + "Slice": 3, + + "Segments": 10, + + "Gang Type": "primary reader", + + "Join Type": "Left", + + "Startup Cost": 2432.00, + + "Total Cost": 8569.25, + + "Plan Rows": 77900, + + "Plan Width": 84, + + "Actual Startup Time": 0.000, + + "Actual Total Time": 0.000, + + "Actual Rows": 0, + + "Actual Loops": 0, + + "Hash Cond": "boxes.location_id = locations.id", + + "Plans": [ + + { + + "Node Type": "Redistribute Motion", + + "Senders": 3, + + "Receivers": 3, + + "Parent Relationship": "Outer", + + "Slice": 2, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Startup Cost": 1216.00, + + "Total Cost": 6282.12, + + "Plan Rows": 77900, + + "Plan Width": 48, + + "Actual Startup Time": 0.000, + + "Actual Total Time": 0.000, + + "Actual Rows": 0, + + "Actual Loops": 0, + + "Hash Key": "boxes.location_id", + + "Plans": [ + + { + + "Node Type": "Hash Join", + + "Parent Relationship": "Outer", + + "Slice": 2, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Join Type": "Left", + + "Startup Cost": 1216.00, + + "Total Cost": 4724.12, + + "Plan Rows": 77900, + + "Plan Width": 48, + + "Actual Startup Time": 0.000, + + "Actual Total Time": 0.000, + + "Actual Rows": 0, + + "Actual Loops": 0, + + "Hash Cond": "boxes.apple_id = apples.id",+ + "Plans": [ + + { + + "Node Type": "Redistribute Motion", + + "Senders": 3, + + "Receivers": 3, + + "Parent Relationship": "Outer", + + "Slice": 1, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Startup Cost": 0.00, + + "Total Cost": 2437.00, + + "Plan Rows": 77900, + + "Plan Width": 12, + + "Actual Startup Time": 0.000, + + "Actual Total Time": 0.000, + + "Actual Rows": 0, + + "Actual Loops": 0, + + "Hash Key": "boxes.apple_id", + + "Plans": [ + + { + + "Node Type": "Seq Scan", + + "Parent Relationship": "Outer", + + "Slice": 1, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Relation Name": "boxes", + + "Alias": "boxes", + + "Startup Cost": 0.00, + + "Total Cost": 879.00, + + "Plan Rows": 77900, + + "Plan Width": 12, + + "Actual Startup Time": 0.000, + + "Actual Total Time": 0.000, + + "Actual Rows": 0, + + "Actual Loops": 0 + + } + + ] + + }, + + { + + "Node Type": "Hash", + + "Parent Relationship": "Inner", + + "Slice": 2, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Startup Cost": 596.00, + + "Total Cost": 596.00, + + "Plan Rows": 49600, + + "Plan Width": 36, + + "Actual Startup Time": 0.000, + + "Actual Total Time": 0.000, + + "Actual Rows": 0, + + "Actual Loops": 0, + + "Plans": [ + + { + + "Node Type": "Seq Scan", + + "Parent Relationship": "Outer", + + "Slice": 2, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Relation Name": "apples", + + "Alias": "apples", + + "Startup Cost": 0.00, + + "Total Cost": 596.00, + + "Plan Rows": 49600, + + "Plan Width": 36, + + "Actual Startup Time": 0.000, + + "Actual Total Time": 0.000, + + "Actual Rows": 0, + + "Actual Loops": 0 + + } + + ] + + } + + ] + + } + + ] + + }, + + { + + "Node Type": "Hash", + + "Parent Relationship": "Inner", + + "Slice": 3, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Startup Cost": 596.00, + + "Total Cost": 596.00, + + "Plan Rows": 49600, + + "Plan Width": 36, + + "Actual Startup Time": 0.000, + + "Actual Total Time": 0.000, + + "Actual Rows": 0, + + "Actual Loops": 0, + + "Plans": [ + + { + + "Node Type": "Seq Scan", + + "Parent Relationship": "Outer", + + "Slice": 3, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Relation Name": "locations", + + "Alias": "locations", + + "Startup Cost": 0.00, + + "Total Cost": 59.00, + + "Plan Rows": 4960, + + "Plan Width": 1, + + "Actual Startup Time": 5.000, + + "Actual Total Time": 10.000, + + "Actual Rows": 5, + + "Actual Loops": 1 + + } + + ] + + } + + ] + + } + + ] + + }, + + "Triggers": [ + + ], + + "Statement statistics": { + + "Memory used": 12800 + + }, + + "Settings": { + + "Optimizer": "legacy query optimizer" + + }, + + "Total Runtime": 28.324 + + } + + ] +(1 row) + +-- explain_processing_on +-- XML Required replaces for costs and time changes +-- start_matchsubs +-- m/Cost>\d+\.\d+<\/[^>]+\-Cost>\s+/ +-- s/Cost>\d+\.\d+<\/([^>]+)\-Cost>\s+/Cost>###.##<\/$1-Cost>/ +-- m/Plan-Rows>\d+<\/Plan-Rows>\s+/ +-- s/Plan-Rows>\d+<\/Plan-Rows>\s+/Plan-Rows>###<\/Plan-Rows>/ +-- m/Plan-Width>\d+<\/Plan-Width>\s+/ +-- s/Plan-Width>\d+<\/Plan-Width>\s+/Plan-Width>###<\/Plan-Width>/ +-- m/Segments>\d+<\/Segments>\s+/ +-- s/Segments>\d+<\/Segments>\s+/Segments>##<\/Segments>/ +-- m/-Time>\d+\.\d+<\/[^>]+\-Time>\s+/ +-- s/-Time>\d+\.\d+<\/([^>]+)\-Time>\s+/-Time>##.###<\/$1-Time>/ +-- m/Total-Runtime>\d+\.\d+<\/Total-Runtime>\s+/ +-- s/Total-Runtime>\d+\.\d+<\/Total-Runtime>\s+/Total-Runtime>##.###<\/Total-Runtime>/ +-- m/Memory-used>\d+<\/Memory-used>\s+/ +-- s/Memory-used>\d+<\/Memory-used>\s+/Memory-used>###<\/Memory-used>/ +-- m/PQO version \d+\.\d+\.\d+/ +-- s/PQO version \d+\.\d+\.\d+/PQO version ##.##.##/ +-- end_matchsubs +-- explain_processing_off +-- Check Explain XML output +EXPLAIN (FORMAT XML) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; + QUERY PLAN +---------------------------------------------------------------------------- + + + + + + + Gather Motion + + 3 + + 1 + + 3 + + 4 + + primary reader + + 22.00 + + 89.25 + + 77900 + + 84 + + + + + + Hash Join + + Outer + + 3 + + 3 + + primary reader + + Left + + 2432.00 + + 8569.25 + + 77900 + + 84 + + boxes.location_id = locations.id + + + + + + Redistribute Motion + + 3 + + 3 + + Outer + + 2 + + 3 + + primary reader + + 1216.00 + + 6282.12 + + 77900 + + 48 + + boxes.location_id + + + + + + Hash Join + + Outer + + 2 + + 3 + + primary reader + + Left + + 1216.00 + + 4724.12 + + 77900 + + 48 + + boxes.apple_id = apples.id + + + + + + Redistribute Motion + + 3 + + 3 + + Outer + + 1 + + 3 + + primary reader + + 0.00 + + 2437.00 + + 77900 + + 12 + + boxes.apple_id + + + + + + Seq Scan + + Outer+ + 1 + + 3 + + primary reader + + boxes + + boxes + + 0.00 + + 879.00 + + 77900 + + 12 + + + + + + + + + + Hash + + Inner + + 2 + + 3 + + primary reader + + 596.00 + + 596.00 + + 49600 + + 36 + + + + + + Seq Scan + + Outer+ + 2 + + 4 + + primary reader + + apples + + apples + + 1.00 + + 5.00 + + 490 + + 6 + + + + + + + + + + + + + + + + + + Hash + + Inner + + 3 + + 3 + + primary reader + + 596.00 + + 596.00 + + 49600 + + 36 + + + + + + Seq Scan + + Outer + + 3 + + 3 + + primary reader + + locations + + locations + + 0.00 + + 596.00 + + 49600 + + 36 + + + + + + + + + + + + + + + + + + legacy query optimizer + + + + + + +(1 row) + +-- explain_processing_on +-- explain_processing_off +-- Check Explain Analyze XML output +EXPLAIN (ANALYZE, FORMAT XML) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; + QUERY PLAN +---------------------------------------------------------------------------- + + + + + + + Gather Motion + + 3 + + 1 + + 3 + + 3 + + primary reader + + 2432.00 + + 8569.25 + + 77900 + + 84 + + 2.978 + + 2.978 + + 0 + + 1 + + + + + + Hash Join + + Outer + + 3 + + 3 + + primary reader + + Left + + 2432.00 + + 8569.25 + + 77900 + + 84 + + 0.000 + + 0.000 + + 0 + + 0 + + boxes.location_id = locations.id + + + + + + Redistribute Motion + + 3 + + 3 + + Outer + + 2 + + 3 + + primary reader + + 1216.00 + + 6282.12 + + 77900 + + 48 + + 0.000 + + 0.000 + + 0 + + 0 + + boxes.location_id + + + + + + Hash Join + + Outer + + 2 + + 3 + + primary reader + + Left + + 1216.00 + + 4724.12 + + 77900 + + 48 + + 0.000 + + 0.000 + + 0 + + 0 + + boxes.apple_id = apples.id + + + + + + Redistribute Motion + + 3 + + 3 + + Outer + + 1 + + 3 + + primary reader + + 0.00 + + 2437.00 + + 77900 + + 12 + + 0.000 + + 0.000 + + 0 + + 0 + + boxes.apple_id + + + + + + Seq Scan + + Outer+ + 1 + + 3 + + primary reader + + boxes + + boxes + + 0.00 + + 879.00 + + 77900 + + 12 + + 0.000+ + 0.000 + + 0 + + 0 + + + + + + + + + + Hash + + Inner + + 2 + + 3 + + primary reader + + 596.00 + + 596.00 + + 49600 + + 36 + + 0.000 + + 0.000 + + 0 + + 0 + + + + + + Seq Scan + + Outer+ + 2 + + 3 + + primary reader + + apples + + apples + + 0.00 + + 596.00 + + 49600 + + 36 + + 0.000+ + 0.000 + + 0 + + 0 + + + + + + + + + + + + + + + + + + Hash + + Inner + + 3 + + 3 + + primary reader + + 59.00 + + 59.00 + + 4960 + + 36 + + 0.000 + + 0.000 + + 0 + + 0 + + + + + + Seq Scan + + Outer + + 3 + + 1 + + primary reader + + locations + + locations + + 0.00 + + 596.00 + + 49600 + + 36 + + 1.000 + + 10.000 + + 0 + + 0 + + + + + + + + + + + + + + + + + + + + + + 1200 + + + + + + legacy query optimizer + + + + 24.8 + + + + +(1 row) + +-- explain_processing_on diff --git a/src/test/regress/expected/explain_format_optimizer.out b/src/test/regress/expected/explain_format_optimizer.out new file mode 100644 index 0000000000000000000000000000000000000000..155a032cc6ebcd6d4b215ab7d826c51062093b68 --- /dev/null +++ b/src/test/regress/expected/explain_format_optimizer.out @@ -0,0 +1,1137 @@ +-- start_matchsubs +-- m/\(actual time=\d+.\d+..\d+.\d+ rows=\d+ loops=\d+\)/ +-- s/\(actual time=\d+.\d+..\d+.\d+ rows=\d+ loops=\d+\)/(actual time=10.302..10.302 rows=0 loops=1)/ +-- m/\(slice\d+\) Executor memory: (\d+)\w bytes\./ +-- s/\(slice\d+\) Executor memory: (\d+)\w bytes\./\(slice\) Executor memory: (#####)K bytes./ +-- m/\(slice\d+\) Executor memory: (\d+)\w bytes avg x \d+ workers, \d+\w bytes max \(seg\d+\)\./ +-- s/\(slice\d+\) Executor memory: (\d+)\w bytes avg x \d+ workers, \d+\w bytes max \(seg\d+\)\./\(slice\) Executor memory: ####K bytes avg x #### workers, ####K bytes max (seg0)./ +-- m/Total runtime: \d+\.\d+ ms/ +-- s/Total runtime: \d+\.\d+ ms/Total runtime: ##.### ms/ +-- m/cost=\d+\.\d+\.\.\d+\.\d+ rows=\d+ width=\d+/ +-- s/\(cost=\d+\.\d+\.\.\d+\.\d+ rows=\d+ width=\d+\)/(cost=##.###..##.### rows=### width=###)/ +-- end_matchsubs +-- +-- DEFAULT syntax +CREATE TABLE apples(id int PRIMARY KEY, type text); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "apples_pkey" for table "apples" +CREATE TABLE locations(id int PRIMARY KEY, address text); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "locations_pkey" for table "locations" +CREATE TABLE boxes(id int PRIMARY KEY, apple_id int REFERENCES apples(id), location_id int REFERENCES locations(id)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "boxes_pkey" for table "boxes" +WARNING: Referential integrity (FOREIGN KEY) constraints are not supported in Greenplum Database, will not be enforced. +WARNING: Referential integrity (FOREIGN KEY) constraints are not supported in Greenplum Database, will not be enforced. +--- Check Explain Text format output +-- explain_processing_off +EXPLAIN SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------ + Gather Motion 3:1 (slice3; segments: 3) (cost=2432.00..8569.25 rows=77900 width=84) + -> Hash Left Join (cost=2432.00..8569.25 rows=25967 width=84) + Hash Cond: boxes.location_id = locations.id + -> Redistribute Motion 3:3 (slice2; segments: 3) (cost=1216.00..6282.12 rows=25967 width=48) + Hash Key: boxes.location_id + -> Hash Left Join (cost=1216.00..4724.12 rows=25967 width=48) + Hash Cond: boxes.apple_id = apples.id + -> Redistribute Motion 3:3 (slice1; segments: 3) (cost=0.00..2437.00 rows=25967 width=12) + Hash Key: boxes.apple_id + -> Table Scan on boxes (cost=0.00..879.00 rows=25967 width=12) + -> Hash (cost=596.00..596.00 rows=16534 width=36) + -> Table Scan on apples (cost=0.00..596.00 rows=16534 width=36) + -> Hash (cost=596.00..596.00 rows=16534 width=36) + -> Table Scan on locations (cost=0.00..596.00 rows=16534 width=36) +(15 rows) + +-- explain_processing_on +--- Check Explain Analyze Text output that include the slices information +-- explain_processing_off +EXPLAIN (ANALYZE) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------- + Gather Motion 3:1 (slice3; segments: 3) (cost=2432.00..8569.25 rows=77900 width=84) (actual time=3.936..3.936 rows=0 loops=1) + -> Hash Left Join (cost=2432.00..8569.25 rows=25967 width=84) (never executed) + Hash Cond: boxes.location_id = locations.id + -> Redistribute Motion 3:3 (slice2; segments: 3) (cost=2432.00..8569.25 rows=25967 width=84) (never executed) + Hash Key: boxes.location_id + -> Hash Left Join (cost=2432.00..8569.25 rows=25967 width=84) (never executed) + Hash Cond: boxes.apple_id = apples.id + -> Redistribute Motion 3:3 (slice1; segments: 3) (cost=2432.00..8569.25 rows=25967 width=84) (never executed) + Hash Key: boxes.apple_id + -> Table Scan on boxes (cost=2432.00..8569.25 rows=25967 width=84) (never executed) + -> Hash (cost=2432.00..8569.25 rows=25967 width=84) (never executed) + -> Table Scan on apples (cost=2432.00..8569.25 rows=25967 width=84) (never executed) + -> Hash (cost=2432.00..8569.25 rows=25967 width=84) (never executed) + -> Table Scan on locations (cost=2432.00..8569.25 rows=25967 width=84) (never executed) + (slice0) Executor memory: 386K bytes. + (slice1) Executor memory: 59K bytes avg x 3 workers, 59K bytes max (seg0). + (slice2) Executor memory: 1110K bytes avg x 3 workers, 1110K bytes max (seg0). + (slice3) Executor memory: 1110K bytes avg x 3 workers, 1110K bytes max (seg0). + Memory used: 128000kB + Total runtime: 34.572 ms +(21 rows) + +-- explain_processing_on +-- YAML Required replaces for costs and time changes +-- start_matchsubs +-- m/ Loops: \d+ / +-- s/ Loops: \d+\s+/ Loops: # / +-- m/ Cost: \d+\.\d+ / +-- s/ Cost: \d+\.\d+\s+/ Cost: ###.## / +-- m/ Rows: \d+ / +-- s/ Rows: \d+\s+/ Rows: ##### / +-- m/ Plan Width: \d+ / +-- s/ Plan Width: \d+\s+/ Plan Width: ## / +-- m/ Time: \d+\.\d+ / +-- s/ Time: \d+\.\d+\s+/ Time: ##.### / +-- m/Total Runtime: \d+\.\d+/ +-- s/Total Runtime: \d+\.\d+/Total Runtime: ##.###/ +-- m/Segments: \d+\s+/ +-- s/Segments: \d+\s+/Segments: #/ +-- m/PQO version \d+\.\d+\.\d+"\s+/ +-- s/PQO version \d+\.\d+\.\d+"\s+/PQO version ##.##.##"/ +-- end_matchsubs +-- Check Explain YAML output +EXPLAIN (FORMAT YAML) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; + QUERY PLAN +--------------------------------------------------------- + - Plan: + + Node Type: "Gather Motion" + + Senders: 3 + + Receivers: 1 + + Slice: 3 + + Segments: 3 + + Gang Type: "primary reader" + + Startup Cost: 2432.00 + + Total Cost: 8569.25 + + Plan Rows: 77900 + + Plan Width: 84 + + Plans: + + - Node Type: "Hash Join" + + Parent Relationship: "Outer" + + Slice: 3 + + Segments: 3 + + Gang Type: "primary reader" + + Join Type: "Left" + + Startup Cost: 2432.00 + + Total Cost: 8569.25 + + Plan Rows: 77900 + + Plan Width: 84 + + Hash Cond: "boxes.location_id = locations.id" + + Plans: + + - Node Type: "Redistribute Motion" + + Senders: 3 + + Receivers: 3 + + Parent Relationship: "Outer" + + Slice: 2 + + Segments: 3 + + Gang Type: "primary reader" + + Startup Cost: 1216.00 + + Total Cost: 6282.12 + + Plan Rows: 77900 + + Plan Width: 48 + + Hash Key: "boxes.location_id" + + Plans: + + - Node Type: "Hash Join" + + Parent Relationship: "Outer" + + Slice: 2 + + Segments: 3 + + Gang Type: "primary reader" + + Join Type: "Left" + + Startup Cost: 1216.00 + + Total Cost: 4724.12 + + Plan Rows: 77900 + + Plan Width: 48 + + Hash Cond: "boxes.apple_id = apples.id"+ + Plans: + + - Node Type: "Redistribute Motion" + + Senders: 3 + + Receivers: 3 + + Parent Relationship: "Outer" + + Slice: 1 + + Segments: 3 + + Gang Type: "primary reader" + + Startup Cost: 0.00 + + Total Cost: 2437.00 + + Plan Rows: 77900 + + Plan Width: 12 + + Hash Key: "boxes.apple_id" + + Plans: + + - Node Type: "Table Scan" + + Parent Relationship: "Outer" + + Slice: 1 + + Segments: 3 + + Gang Type: "primary reader" + + Relation Name: "boxes" + + Alias: "boxes" + + Startup Cost: 0.00 + + Total Cost: 879.00 + + Plan Rows: 77900 + + Plan Width: 12 + + - Node Type: "Hash" + + Parent Relationship: "Inner" + + Slice: 2 + + Segments: 3 + + Gang Type: "primary reader" + + Startup Cost: 596.00 + + Total Cost: 596.00 + + Plan Rows: 49600 + + Plan Width: 36 + + Plans: + + - Node Type: "Table Scan" + + Parent Relationship: "Outer" + + Slice: 2 + + Segments: 3 + + Gang Type: "primary reader" + + Relation Name: "apples" + + Alias: "apples" + + Startup Cost: 0.00 + + Total Cost: 596.00 + + Plan Rows: 49600 + + Plan Width: 36 + + - Node Type: "Hash" + + Parent Relationship: "Inner" + + Slice: 3 + + Segments: 3 + + Gang Type: "primary reader" + + Startup Cost: 596.00 + + Total Cost: 596.00 + + Plan Rows: 49600 + + Plan Width: 36 + + Plans: + + - Node Type: "Table Scan" + + Parent Relationship: "Outer" + + Slice: 3 + + Segments: 10 + + Gang Type: "primary reader" + + Relation Name: "locations" + + Alias: "locations" + + Startup Cost: 0.00 + + Total Cost: 596.00 + + Plan Rows: 49600 + + Plan Width: 36 + + Settings: + + Optimizer: "PQO version 1.2.3" +(1 row) + +--- Check Explain Analyze YAML output that include the slices information +-- explain_processing_off +EXPLAIN (ANALYZE, FORMAT YAML) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; + QUERY PLAN +--------------------------------------------------------- + - Plan: + + Node Type: "Gather Motion" + + Senders: 3 + + Receivers: 1 + + Slice: 3 + + Segments: 3 + + Gang Type: "primary reader" + + Startup Cost: 2432.00 + + Total Cost: 8569.25 + + Plan Rows: 77901 + + Plan Width: 100 + + Actual Startup Time: 1.842 + + Actual Total Time: 1.842 + + Actual Rows: 50 + + Actual Loops: 3 + + Plans: + + - Node Type: "Hash Join" + + Parent Relationship: "Outer" + + Slice: 3 + + Segments: 3 + + Gang Type: "primary reader" + + Join Type: "Left" + + Startup Cost: 2432.00 + + Total Cost: 8569.25 + + Plan Rows: 900 + + Plan Width: 84 + + Actual Startup Time: 0.000 + + Actual Total Time: 0.000 + + Actual Rows: 0 + + Actual Loops: 0 + + Hash Cond: "boxes.location_id = locations.id" + + Plans: + + - Node Type: "Redistribute Motion" + + Senders: 3 + + Receivers: 3 + + Parent Relationship: "Outer" + + Slice: 2 + + Segments: 3 + + Gang Type: "primary reader" + + Startup Cost: 1216.00 + + Total Cost: 6282.12 + + Plan Rows: 77900 + + Plan Width: 48 + + Actual Startup Time: 0.000 + + Actual Total Time: 0.000 + + Actual Rows: 0 + + Actual Loops: 0 + + Hash Key: "boxes.location_id" + + Plans: + + - Node Type: "Hash Join" + + Parent Relationship: "Outer" + + Slice: 2 + + Segments: 3 + + Gang Type: "primary reader" + + Join Type: "Left" + + Startup Cost: 1216.00 + + Total Cost: 4724.12 + + Plan Rows: 77900 + + Plan Width: 48 + + Actual Startup Time: 0.000 + + Actual Total Time: 0.000 + + Actual Rows: 0 + + Actual Loops: 0 + + Hash Cond: "boxes.apple_id = apples.id"+ + Plans: + + - Node Type: "Redistribute Motion" + + Senders: 3 + + Receivers: 3 + + Parent Relationship: "Outer" + + Slice: 1 + + Segments: 3 + + Gang Type: "primary reader" + + Startup Cost: 0.00 + + Total Cost: 2437.00 + + Plan Rows: 77900 + + Plan Width: 12 + + Actual Startup Time: 0.000 + + Actual Total Time: 0.000 + + Actual Rows: 0 + + Actual Loops: 0 + + Hash Key: "boxes.apple_id" + + Plans: + + - Node Type: "Table Scan" + + Parent Relationship: "Outer" + + Slice: 1 + + Segments: 3 + + Gang Type: "primary reader" + + Relation Name: "boxes" + + Alias: "boxes" + + Startup Cost: 0.00 + + Total Cost: 879.00 + + Plan Rows: 77900 + + Plan Width: 12 + + Actual Startup Time: 0.000 + + Actual Total Time: 0.000 + + Actual Rows: 0 + + Actual Loops: 0 + + - Node Type: "Hash" + + Parent Relationship: "Inner" + + Slice: 2 + + Segments: 3 + + Gang Type: "primary reader" + + Startup Cost: 596.00 + + Total Cost: 596.00 + + Plan Rows: 49600 + + Plan Width: 36 + + Actual Startup Time: 0.000 + + Actual Total Time: 0.000 + + Actual Rows: 0 + + Actual Loops: 0 + + Plans: + + - Node Type: "Table Scan" + + Parent Relationship: "Outer" + + Slice: 2 + + Segments: 3 + + Gang Type: "primary reader" + + Relation Name: "apples" + + Alias: "apples" + + Startup Cost: 0.00 + + Total Cost: 596.00 + + Plan Rows: 49600 + + Plan Width: 36 + + Actual Startup Time: 0.000 + + Actual Total Time: 0.000 + + Actual Rows: 0 + + Actual Loops: 0 + + - Node Type: "Hash" + + Parent Relationship: "Inner" + + Slice: 3 + + Segments: 3 + + Gang Type: "primary reader" + + Startup Cost: 596.00 + + Total Cost: 596.00 + + Plan Rows: 49600 + + Plan Width: 36 + + Actual Startup Time: 0.000 + + Actual Total Time: 0.000 + + Actual Rows: 0 + + Actual Loops: 0 + + Plans: + + - Node Type: "Table Scan" + + Parent Relationship: "Outer" + + Slice: 3 + + Segments: 10 + + Gang Type: "primary reader" + + Relation Name: "locations" + + Alias: "locations" + + Startup Cost: 0.00 + + Total Cost: 596.00 + + Plan Rows: 49600 + + Plan Width: 36 + + Actual Startup Time: 0.000 + + Actual Total Time: 0.000 + + Actual Rows: 0 + + Actual Loops: 0 + + Triggers: + + Statement statistics: + + Memory used: 128000 + + Settings: + + Optimizer: "PQO version 1.2.3" + + Total Runtime: 2.652 +(1 row) + +-- explain_processing_on +-- JSON Required replaces for costs and time changes +-- start_matchsubs +-- m/ Loops": \d+,?\s+/ +-- s/ Loops": \d+,?\s+/ Loops": #, / +-- m/ Cost": \d+\.\d+, / +-- s/ Cost": \d+\.\d+,\s+/ Cost": ###.##, / +-- m/ Rows": \d+, / +-- s/ Rows": \d+,\s+/ Rows": #####, / +-- m/"Plan Width": \d+,? / +-- s/"Plan Width": \d+,?\s+/"Plan Width": ##, / +-- m/ Time": \d+\.\d+, / +-- s/ Time": \d+\.\d+,\s+/ Time": ##.###, / +-- m/Total Runtime": \d+\.\d+,?\s+/ +-- s/Total Runtime": \d+\.\d+,?\s+/Total Runtime": ##.###,/ +-- m/"Memory used": \d+,?\s+/ +-- s/"Memory used": \d+,?\s+/"Memory used": ####,/ +-- m/"Segments": \d+,\s+/ +-- s/"Segments": \d+,\s+/"Segments": #,/ +-- end_matchsubs +-- explain_processing_off +-- Check Explain JSON output +EXPLAIN (FORMAT JSON) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; + QUERY PLAN +-------------------------------------------------------------- + [ + + { + + "Plan": { + + "Node Type": "Gather Motion", + + "Senders": 3, + + "Receivers": 1, + + "Slice": 3, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Startup Cost": 242.00, + + "Total Cost": 859.25, + + "Plan Rows": 7790, + + "Plan Width": 10, + + "Plans": [ + + { + + "Node Type": "Hash Join", + + "Parent Relationship": "Outer", + + "Slice": 3, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Join Type": "Left", + + "Startup Cost": 242.00, + + "Total Cost": 859.25, + + "Plan Rows": 7700, + + "Plan Width": 10, + + "Hash Cond": "boxes.location_id = locations.id", + + "Plans": [ + + { + + "Node Type": "Redistribute Motion", + + "Senders": 3, + + "Receivers": 3, + + "Parent Relationship": "Outer", + + "Slice": 2, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Startup Cost": 121.00, + + "Total Cost": 628.12, + + "Plan Rows": 7790, + + "Plan Width": 4, + + "Hash Key": "boxes.location_id", + + "Plans": [ + + { + + "Node Type": "Hash Join", + + "Parent Relationship": "Outer", + + "Slice": 2, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Join Type": "Left", + + "Startup Cost": 1216.00, + + "Total Cost": 4724.12, + + "Plan Rows": 77900, + + "Plan Width": 48, + + "Hash Cond": "boxes.apple_id = apples.id",+ + "Plans": [ + + { + + "Node Type": "Redistribute Motion", + + "Senders": 3, + + "Receivers": 3, + + "Parent Relationship": "Outer", + + "Slice": 1, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Startup Cost": 0.00, + + "Total Cost": 2437.00, + + "Plan Rows": 77900, + + "Plan Width": 12, + + "Hash Key": "boxes.apple_id", + + "Plans": [ + + { + + "Node Type": "Table Scan", + + "Parent Relationship": "Outer", + + "Slice": 1, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Relation Name": "boxes", + + "Alias": "boxes", + + "Startup Cost": 0.00, + + "Total Cost": 879.00, + + "Plan Rows": 77900, + + "Plan Width": 12 + + } + + ] + + }, + + { + + "Node Type": "Hash", + + "Parent Relationship": "Inner", + + "Slice": 2, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Startup Cost": 596.00, + + "Total Cost": 596.00, + + "Plan Rows": 49600, + + "Plan Width": 36, + + "Plans": [ + + { + + "Node Type": "Table Scan", + + "Parent Relationship": "Outer", + + "Slice": 2, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Relation Name": "apples", + + "Alias": "apples", + + "Startup Cost": 0.00, + + "Total Cost": 596.00, + + "Plan Rows": 49600, + + "Plan Width": 36 + + } + + ] + + } + + ] + + } + + ] + + }, + + { + + "Node Type": "Hash", + + "Parent Relationship": "Inner", + + "Slice": 3, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Startup Cost": 596.00, + + "Total Cost": 596.00, + + "Plan Rows": 49600, + + "Plan Width": 36, + + "Plans": [ + + { + + "Node Type": "Table Scan", + + "Parent Relationship": "Outer", + + "Slice": 3, + + "Segments": 10, + + "Gang Type": "primary reader", + + "Relation Name": "locations", + + "Alias": "locations", + + "Startup Cost": 0.00, + + "Total Cost": 596.00, + + "Plan Rows": 49600, + + "Plan Width": 36 + + } + + ] + + } + + ] + + } + + ] + + }, + + "Settings": { + + "Optimizer": "PQO version 1.2.3" + + } + + } + + ] +(1 row) + +-- explain_processing_on +--- Check Explain Analyze JSON output that include the slices information +-- explain_processing_off +EXPLAIN (ANALYZE, FORMAT JSON) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; + QUERY PLAN +-------------------------------------------------------------- + [ + + { + + "Plan": { + + "Node Type": "Gather Motion", + + "Senders": 3, + + "Receivers": 1, + + "Slice": 3, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Startup Cost": 2432.00, + + "Total Cost": 8569.25, + + "Plan Rows": 77900, + + "Plan Width": 84, + + "Actual Startup Time": 5.415, + + "Actual Total Time": 5.415, + + "Actual Rows": 0, + + "Actual Loops": 1, + + "Plans": [ + + { + + "Node Type": "Hash Join", + + "Parent Relationship": "Outer", + + "Slice": 3, + + "Segments": 10, + + "Gang Type": "primary reader", + + "Join Type": "Left", + + "Startup Cost": 2432.00, + + "Total Cost": 8569.25, + + "Plan Rows": 77900, + + "Plan Width": 84, + + "Actual Startup Time": 0.000, + + "Actual Total Time": 0.000, + + "Actual Rows": 0, + + "Actual Loops": 0, + + "Hash Cond": "boxes.location_id = locations.id", + + "Plans": [ + + { + + "Node Type": "Redistribute Motion", + + "Senders": 3, + + "Receivers": 3, + + "Parent Relationship": "Outer", + + "Slice": 2, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Startup Cost": 1216.00, + + "Total Cost": 6282.12, + + "Plan Rows": 77900, + + "Plan Width": 48, + + "Actual Startup Time": 0.000, + + "Actual Total Time": 0.000, + + "Actual Rows": 0, + + "Actual Loops": 0, + + "Hash Key": "boxes.location_id", + + "Plans": [ + + { + + "Node Type": "Hash Join", + + "Parent Relationship": "Outer", + + "Slice": 2, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Join Type": "Left", + + "Startup Cost": 1216.00, + + "Total Cost": 4724.12, + + "Plan Rows": 77900, + + "Plan Width": 48, + + "Actual Startup Time": 0.000, + + "Actual Total Time": 0.000, + + "Actual Rows": 0, + + "Actual Loops": 0, + + "Hash Cond": "boxes.apple_id = apples.id",+ + "Plans": [ + + { + + "Node Type": "Redistribute Motion", + + "Senders": 3, + + "Receivers": 3, + + "Parent Relationship": "Outer", + + "Slice": 1, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Startup Cost": 0.00, + + "Total Cost": 2437.00, + + "Plan Rows": 77900, + + "Plan Width": 12, + + "Actual Startup Time": 0.000, + + "Actual Total Time": 0.000, + + "Actual Rows": 0, + + "Actual Loops": 0, + + "Hash Key": "boxes.apple_id", + + "Plans": [ + + { + + "Node Type": "Table Scan", + + "Parent Relationship": "Outer", + + "Slice": 1, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Relation Name": "boxes", + + "Alias": "boxes", + + "Startup Cost": 0.00, + + "Total Cost": 879.00, + + "Plan Rows": 77900, + + "Plan Width": 12, + + "Actual Startup Time": 0.000, + + "Actual Total Time": 0.000, + + "Actual Rows": 0, + + "Actual Loops": 0 + + } + + ] + + }, + + { + + "Node Type": "Hash", + + "Parent Relationship": "Inner", + + "Slice": 2, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Startup Cost": 596.00, + + "Total Cost": 596.00, + + "Plan Rows": 49600, + + "Plan Width": 36, + + "Actual Startup Time": 0.000, + + "Actual Total Time": 0.000, + + "Actual Rows": 0, + + "Actual Loops": 0, + + "Plans": [ + + { + + "Node Type": "Table Scan", + + "Parent Relationship": "Outer", + + "Slice": 2, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Relation Name": "apples", + + "Alias": "apples", + + "Startup Cost": 0.00, + + "Total Cost": 596.00, + + "Plan Rows": 49600, + + "Plan Width": 36, + + "Actual Startup Time": 0.000, + + "Actual Total Time": 0.000, + + "Actual Rows": 0, + + "Actual Loops": 0 + + } + + ] + + } + + ] + + } + + ] + + }, + + { + + "Node Type": "Hash", + + "Parent Relationship": "Inner", + + "Slice": 3, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Startup Cost": 596.00, + + "Total Cost": 596.00, + + "Plan Rows": 49600, + + "Plan Width": 36, + + "Actual Startup Time": 0.000, + + "Actual Total Time": 0.000, + + "Actual Rows": 0, + + "Actual Loops": 0, + + "Plans": [ + + { + + "Node Type": "Table Scan", + + "Parent Relationship": "Outer", + + "Slice": 3, + + "Segments": 3, + + "Gang Type": "primary reader", + + "Relation Name": "locations", + + "Alias": "locations", + + "Startup Cost": 0.00, + + "Total Cost": 59.00, + + "Plan Rows": 4960, + + "Plan Width": 1, + + "Actual Startup Time": 5.000, + + "Actual Total Time": 10.000, + + "Actual Rows": 5, + + "Actual Loops": 1 + + } + + ] + + } + + ] + + } + + ] + + }, + + "Triggers": [ + + ], + + "Statement statistics": { + + "Memory used": 12800 + + }, + + "Settings": { + + "Optimizer": "PQO version 1.2.3" + + }, + + "Total Runtime": 28.324 + + } + + ] +(1 row) + +-- explain_processing_on +-- XML Required replaces for costs and time changes +-- start_matchsubs +-- m/Cost>\d+\.\d+<\/[^>]+\-Cost>\s+/ +-- s/Cost>\d+\.\d+<\/([^>]+)\-Cost>\s+/Cost>###.##<\/$1-Cost>/ +-- m/Plan-Rows>\d+<\/Plan-Rows>\s+/ +-- s/Plan-Rows>\d+<\/Plan-Rows>\s+/Plan-Rows>###<\/Plan-Rows>/ +-- m/Plan-Width>\d+<\/Plan-Width>\s+/ +-- s/Plan-Width>\d+<\/Plan-Width>\s+/Plan-Width>###<\/Plan-Width>/ +-- m/Segments>\d+<\/Segments>\s+/ +-- s/Segments>\d+<\/Segments>\s+/Segments>##<\/Segments>/ +-- m/-Time>\d+\.\d+<\/[^>]+\-Time>\s+/ +-- s/-Time>\d+\.\d+<\/([^>]+)\-Time>\s+/-Time>##.###<\/$1-Time>/ +-- m/Total-Runtime>\d+\.\d+<\/Total-Runtime>\s+/ +-- s/Total-Runtime>\d+\.\d+<\/Total-Runtime>\s+/Total-Runtime>##.###<\/Total-Runtime>/ +-- m/Memory-used>\d+<\/Memory-used>\s+/ +-- s/Memory-used>\d+<\/Memory-used>\s+/Memory-used>###<\/Memory-used>/ +-- m/PQO version \d+\.\d+\.\d+/ +-- s/PQO version \d+\.\d+\.\d+/PQO version ##.##.##/ +-- end_matchsubs +-- explain_processing_off +-- Check Explain XML output +EXPLAIN (FORMAT XML) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; + QUERY PLAN +---------------------------------------------------------------------------- + + + + + + + Gather Motion + + 3 + + 1 + + 3 + + 4 + + primary reader + + 22.00 + + 89.25 + + 77900 + + 84 + + + + + + Hash Join + + Outer + + 3 + + 3 + + primary reader + + Left + + 2432.00 + + 8569.25 + + 77900 + + 84 + + boxes.location_id = locations.id + + + + + + Redistribute Motion + + 3 + + 3 + + Outer + + 2 + + 3 + + primary reader + + 1216.00 + + 6282.12 + + 77900 + + 48 + + boxes.location_id + + + + + + Hash Join + + Outer + + 2 + + 3 + + primary reader + + Left + + 1216.00 + + 4724.12 + + 77900 + + 48 + + boxes.apple_id = apples.id + + + + + + Redistribute Motion + + 3 + + 3 + + Outer + + 1 + + 3 + + primary reader + + 0.00 + + 2437.00 + + 77900 + + 12 + + boxes.apple_id + + + + + + Table Scan + + Outer+ + 1 + + 3 + + primary reader + + boxes + + boxes + + 0.00 + + 879.00 + + 77900 + + 12 + + + + + + + + + + Hash + + Inner + + 2 + + 3 + + primary reader + + 596.00 + + 596.00 + + 49600 + + 36 + + + + + + Table Scan + + Outer+ + 2 + + 4 + + primary reader + + apples + + apples + + 1.00 + + 5.00 + + 490 + + 6 + + + + + + + + + + + + + + + + + + Hash + + Inner + + 3 + + 3 + + primary reader + + 596.00 + + 596.00 + + 49600 + + 36 + + + + + + Table Scan + + Outer + + 3 + + 3 + + primary reader + + locations + + locations + + 0.00 + + 596.00 + + 49600 + + 36 + + + + + + + + + + + + + + + + + + PQO version 1.2.3 + + + + + + +(1 row) + +-- explain_processing_on +-- explain_processing_off +-- Check Explain Analyze XML output +EXPLAIN (ANALYZE, FORMAT XML) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; + QUERY PLAN +---------------------------------------------------------------------------- + + + + + + + Gather Motion + + 3 + + 1 + + 3 + + 3 + + primary reader + + 2432.00 + + 8569.25 + + 77900 + + 84 + + 2.978 + + 2.978 + + 0 + + 1 + + + + + + Hash Join + + Outer + + 3 + + 3 + + primary reader + + Left + + 2432.00 + + 8569.25 + + 77900 + + 84 + + 0.000 + + 0.000 + + 0 + + 0 + + boxes.location_id = locations.id + + + + + + Redistribute Motion + + 3 + + 3 + + Outer + + 2 + + 3 + + primary reader + + 1216.00 + + 6282.12 + + 77900 + + 48 + + 0.000 + + 0.000 + + 0 + + 0 + + boxes.location_id + + + + + + Hash Join + + Outer + + 2 + + 3 + + primary reader + + Left + + 1216.00 + + 4724.12 + + 77900 + + 48 + + 0.000 + + 0.000 + + 0 + + 0 + + boxes.apple_id = apples.id + + + + + + Redistribute Motion + + 3 + + 3 + + Outer + + 1 + + 3 + + primary reader + + 0.00 + + 2437.00 + + 77900 + + 12 + + 0.000 + + 0.000 + + 0 + + 0 + + boxes.apple_id + + + + + + Table Scan + + Outer+ + 1 + + 3 + + primary reader + + boxes + + boxes + + 0.00 + + 879.00 + + 77900 + + 12 + + 0.000+ + 0.000 + + 0 + + 0 + + + + + + + + + + Hash + + Inner + + 2 + + 3 + + primary reader + + 596.00 + + 596.00 + + 49600 + + 36 + + 0.000 + + 0.000 + + 0 + + 0 + + + + + + Table Scan + + Outer+ + 2 + + 3 + + primary reader + + apples + + apples + + 0.00 + + 596.00 + + 49600 + + 36 + + 0.000+ + 0.000 + + 0 + + 0 + + + + + + + + + + + + + + + + + + Hash + + Inner + + 3 + + 3 + + primary reader + + 59.00 + + 59.00 + + 4960 + + 36 + + 0.000 + + 0.000 + + 0 + + 0 + + + + + + Table Scan + + Outer + + 3 + + 1 + + primary reader + + locations + + locations + + 0.00 + + 596.00 + + 49600 + + 36 + + 1.000 + + 10.000 + + 0 + + 0 + + + + + + + + + + + + + + + + + + + + + + 1200 + + + + + + PQO version 1.2.3 + + + + 24.8 + + + + +(1 row) + +-- explain_processing_on diff --git a/src/test/regress/greenplum_schedule b/src/test/regress/greenplum_schedule index 56fafb70e7bc8a3c695dc7fef95d9f2aabd0652e..0e23ee318b345936a606c6e28c6e148d9e343057 100755 --- a/src/test/regress/greenplum_schedule +++ b/src/test/regress/greenplum_schedule @@ -25,7 +25,7 @@ test: spi_processed64bit test: python_processed64bit test: leastsquares opr_sanity_gp decode_expr bitmapscan bitmapscan_ao case_gp limit_gp notin percentile join_gp union_gp gpcopy gp_create_table gp_create_view window_views -test: filter gpctas gpdist matrix toast sublink table_functions olap_setup complex opclass_ddl information_schema guc_env_var guc_gp gp_explain distributed_transactions +test: filter gpctas gpdist matrix toast sublink table_functions olap_setup complex opclass_ddl information_schema guc_env_var guc_gp gp_explain distributed_transactions explain_format test: bitmap_index gp_dump_query_oids analyze gp_owner_permission incremental_analyze test: indexjoin as_alias regex_gp gpparams with_clause transient_types gp_rules diff --git a/src/test/regress/sql/explain_format.sql b/src/test/regress/sql/explain_format.sql index 282705fe0308b5dd902f44f1ade9affc7b7e65a6..5da2684274b6eedd5b3b3bdf0d2962d4514c6780 100644 --- a/src/test/regress/sql/explain_format.sql +++ b/src/test/regress/sql/explain_format.sql @@ -16,11 +16,97 @@ CREATE TABLE apples(id int PRIMARY KEY, type text); CREATE TABLE locations(id int PRIMARY KEY, address text); CREATE TABLE boxes(id int PRIMARY KEY, apple_id int REFERENCES apples(id), location_id int REFERENCES locations(id)); ---- Check Explain Text output +--- Check Explain Text format output +-- explain_processing_off EXPLAIN SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; +-- explain_processing_on ---- Check Explain Analyze Text output +--- Check Explain Analyze Text output that include the slices information -- explain_processing_off EXPLAIN (ANALYZE) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; -- explain_processing_on +-- YAML Required replaces for costs and time changes +-- start_matchsubs +-- m/ Loops: \d+ / +-- s/ Loops: \d+\s+/ Loops: # / +-- m/ Cost: \d+\.\d+ / +-- s/ Cost: \d+\.\d+\s+/ Cost: ###.## / +-- m/ Rows: \d+ / +-- s/ Rows: \d+\s+/ Rows: ##### / +-- m/ Plan Width: \d+ / +-- s/ Plan Width: \d+\s+/ Plan Width: ## / +-- m/ Time: \d+\.\d+ / +-- s/ Time: \d+\.\d+\s+/ Time: ##.### / +-- m/Total Runtime: \d+\.\d+/ +-- s/Total Runtime: \d+\.\d+/Total Runtime: ##.###/ +-- m/Segments: \d+\s+/ +-- s/Segments: \d+\s+/Segments: #/ +-- m/PQO version \d+\.\d+\.\d+"\s+/ +-- s/PQO version \d+\.\d+\.\d+"\s+/PQO version ##.##.##"/ +-- end_matchsubs +-- Check Explain YAML output +EXPLAIN (FORMAT YAML) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; + +--- Check Explain Analyze YAML output that include the slices information +-- explain_processing_off +EXPLAIN (ANALYZE, FORMAT YAML) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; +-- explain_processing_on + +-- JSON Required replaces for costs and time changes +-- start_matchsubs +-- m/ Loops": \d+,?\s+/ +-- s/ Loops": \d+,?\s+/ Loops": #, / +-- m/ Cost": \d+\.\d+, / +-- s/ Cost": \d+\.\d+,\s+/ Cost": ###.##, / +-- m/ Rows": \d+, / +-- s/ Rows": \d+,\s+/ Rows": #####, / +-- m/"Plan Width": \d+,? / +-- s/"Plan Width": \d+,?\s+/"Plan Width": ##, / +-- m/ Time": \d+\.\d+, / +-- s/ Time": \d+\.\d+,\s+/ Time": ##.###, / +-- m/Total Runtime": \d+\.\d+,?\s+/ +-- s/Total Runtime": \d+\.\d+,?\s+/Total Runtime": ##.###,/ +-- m/"Memory used": \d+,?\s+/ +-- s/"Memory used": \d+,?\s+/"Memory used": ####,/ +-- m/"Segments": \d+,\s+/ +-- s/"Segments": \d+,\s+/"Segments": #,/ +-- end_matchsubs +-- explain_processing_off +-- Check Explain JSON output +EXPLAIN (FORMAT JSON) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; +-- explain_processing_on + +--- Check Explain Analyze JSON output that include the slices information +-- explain_processing_off +EXPLAIN (ANALYZE, FORMAT JSON) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; +-- explain_processing_on + +-- XML Required replaces for costs and time changes +-- start_matchsubs +-- m/Cost>\d+\.\d+<\/[^>]+\-Cost>\s+/ +-- s/Cost>\d+\.\d+<\/([^>]+)\-Cost>\s+/Cost>###.##<\/$1-Cost>/ +-- m/Plan-Rows>\d+<\/Plan-Rows>\s+/ +-- s/Plan-Rows>\d+<\/Plan-Rows>\s+/Plan-Rows>###<\/Plan-Rows>/ +-- m/Plan-Width>\d+<\/Plan-Width>\s+/ +-- s/Plan-Width>\d+<\/Plan-Width>\s+/Plan-Width>###<\/Plan-Width>/ +-- m/Segments>\d+<\/Segments>\s+/ +-- s/Segments>\d+<\/Segments>\s+/Segments>##<\/Segments>/ +-- m/-Time>\d+\.\d+<\/[^>]+\-Time>\s+/ +-- s/-Time>\d+\.\d+<\/([^>]+)\-Time>\s+/-Time>##.###<\/$1-Time>/ +-- m/Total-Runtime>\d+\.\d+<\/Total-Runtime>\s+/ +-- s/Total-Runtime>\d+\.\d+<\/Total-Runtime>\s+/Total-Runtime>##.###<\/Total-Runtime>/ +-- m/Memory-used>\d+<\/Memory-used>\s+/ +-- s/Memory-used>\d+<\/Memory-used>\s+/Memory-used>###<\/Memory-used>/ +-- m/PQO version \d+\.\d+\.\d+/ +-- s/PQO version \d+\.\d+\.\d+/PQO version ##.##.##/ +-- end_matchsubs +-- explain_processing_off +-- Check Explain XML output +EXPLAIN (FORMAT XML) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; +-- explain_processing_on + +-- explain_processing_off +-- Check Explain Analyze XML output +EXPLAIN (ANALYZE, FORMAT XML) SELECT * from boxes LEFT JOIN apples ON apples.id = boxes.apple_id LEFT JOIN locations ON locations.id = boxes.location_id; +-- explain_processing_on