From 28d0a38564da12bf09e736ba210ca8fa5910f52b Mon Sep 17 00:00:00 2001 From: Rebecca Taft Date: Wed, 28 Aug 2019 18:12:42 +0200 Subject: [PATCH] opt: fix statistics estimation for semi and anti joins Prior to this commit, the statisticsBuilder always estimated that the number of output rows for a semi or anti join was equal to the number of rows on the left side. It ignored any ON conditions. This commit improves the estimate by taking into account the ON conditions. Release note: None --- pkg/sql/opt/memo/statistics_builder.go | 110 +++- pkg/sql/opt/memo/testdata/stats/join | 105 +++- pkg/sql/opt/memo/testdata/stats_quality/tpch | 544 ++++++------------ pkg/sql/opt/norm/testdata/rules/decorrelate | 26 +- pkg/sql/opt/norm/testdata/rules/prune_cols | 10 +- pkg/sql/opt/xform/testdata/external/hibernate | 31 +- pkg/sql/opt/xform/testdata/external/tpcc | 68 +-- .../xform/testdata/external/tpcc-later-stats | 68 +-- .../opt/xform/testdata/external/tpcc-no-stats | 68 +-- pkg/sql/opt/xform/testdata/external/tpch | 118 ++-- .../opt/xform/testdata/external/tpch-no-stats | 60 +- pkg/sql/opt/xform/testdata/rules/join | 6 +- 12 files changed, 528 insertions(+), 686 deletions(-) diff --git a/pkg/sql/opt/memo/statistics_builder.go b/pkg/sql/opt/memo/statistics_builder.go index feae3ddf13b2..39f21a587b92 100644 --- a/pkg/sql/opt/memo/statistics_builder.go +++ b/pkg/sql/opt/memo/statistics_builder.go @@ -828,19 +828,11 @@ func (sb *statisticsBuilder) buildJoin( rightCols := h.rightProps.OutputCols.Copy() equivReps := h.filtersFD.EquivReps() - // Estimating selectivity for semi-join and anti-join is error-prone. - // For now, just propagate stats from the left side. - switch h.joinType { - case opt.SemiJoinOp, opt.SemiJoinApplyOp, opt.AntiJoinOp, opt.AntiJoinApplyOp: - s.RowCount = leftStats.RowCount - s.Selectivity = 1 - return - } - // Shortcut if there are no ON conditions. Note that for lookup join, there // are implicit equality conditions on KeyCols. if h.filterIsTrue { s.RowCount = leftStats.RowCount * rightStats.RowCount + s.Selectivity = 1 switch h.joinType { case opt.InnerJoinOp, opt.InnerJoinApplyOp: case opt.LeftJoinOp, opt.LeftJoinApplyOp: @@ -855,13 +847,20 @@ func (sb *statisticsBuilder) buildJoin( // All rows from both sides should be in the result. s.RowCount = max(s.RowCount, leftStats.RowCount) s.RowCount = max(s.RowCount, rightStats.RowCount) + + case opt.SemiJoinOp, opt.SemiJoinApplyOp: + s.RowCount = leftStats.RowCount + + case opt.AntiJoinOp, opt.AntiJoinApplyOp: + s.RowCount = 0 + s.Selectivity = 0 } - s.Selectivity = 1 return } // Shortcut if the ON condition is false or there is a contradiction. if h.filters.IsFalse() { + s.Selectivity = 0 switch h.joinType { case opt.InnerJoinOp, opt.InnerJoinApplyOp: s.RowCount = 0 @@ -877,8 +876,14 @@ func (sb *statisticsBuilder) buildJoin( case opt.FullJoinOp: // All rows from both sides should be in the result. s.RowCount = leftStats.RowCount + rightStats.RowCount + + case opt.SemiJoinOp, opt.SemiJoinApplyOp: + s.RowCount = 0 + + case opt.AntiJoinOp, opt.AntiJoinApplyOp: + s.RowCount = leftStats.RowCount + s.Selectivity = 1 } - s.Selectivity = 0 return } @@ -900,16 +905,36 @@ func (sb *statisticsBuilder) buildJoin( // Calculate selectivity and row count // ----------------------------------- - if h.rightProps.FuncDeps.ColsAreStrictKey(h.selfJoinCols) { - // This is like an index join. + s.RowCount = leftStats.RowCount * rightStats.RowCount + inputRowCount := s.RowCount + switch h.joinType { + case opt.SemiJoinOp, opt.SemiJoinApplyOp, opt.AntiJoinOp, opt.AntiJoinApplyOp: + // Treat anti join as if it were a semi join for the selectivity + // calculations. It will be fixed below. s.RowCount = leftStats.RowCount - } else { - s.RowCount = leftStats.RowCount * rightStats.RowCount - equivReps.UnionWith(h.selfJoinCols) + inputRowCount = s.RowCount + selectivity := sb.selectivityFromEquivalencies(equivReps, &h.filtersFD, join, s) + + // Multiply the selectivity from equivalencies by the right row count to + // account for the fact that semi/anti joins start from the left side row + // count rather than the cross product. + s.ApplySelectivity(min(rightStats.RowCount*selectivity, 1)) + + default: + if h.rightProps.FuncDeps.ColsAreStrictKey(h.selfJoinCols) { + // This is like an index join, so apply a selectivity that will result + // in leftStats.RowCount rows. + s.ApplySelectivity(1 / rightStats.RowCount) + } else { + // Add the self join columns to equivReps so they are included in the + // calculation for selectivityFromEquivalencies below. + equivReps.UnionWith(h.selfJoinCols) + } + + s.ApplySelectivity(sb.selectivityFromEquivalencies(equivReps, &h.filtersFD, join, s)) } - inputRowCount := s.RowCount + s.ApplySelectivity(sb.selectivityFromDistinctCounts(constrainedCols, join, s)) - s.ApplySelectivity(sb.selectivityFromEquivalencies(equivReps, &h.filtersFD, join, s)) s.ApplySelectivity(sb.selectivityFromUnappliedConjuncts(numUnappliedConjuncts)) // Update distinct counts based on equivalencies; this should happen after @@ -919,16 +944,24 @@ func (sb *statisticsBuilder) buildJoin( // Update null counts for non-nullable columns. sb.updateNullCountsFromProps(join, relProps, inputRowCount) - s.ApplySelectivity(sb.joinSelectivityFromNullCounts( - constrainedCols, - join, - s, - inputRowCount, - leftCols, - leftStats.RowCount, - rightCols, - rightStats.RowCount, - )) + switch h.joinType { + case opt.SemiJoinOp, opt.SemiJoinApplyOp, opt.AntiJoinOp, opt.AntiJoinApplyOp: + // Keep only column stats from the left side. + s.ColStats.RemoveIntersecting(h.rightProps.OutputCols) + s.ApplySelectivity(sb.selectivityFromNullCounts(constrainedCols, join, s, inputRowCount)) + + default: + s.ApplySelectivity(sb.joinSelectivityFromNullCounts( + constrainedCols, + join, + s, + inputRowCount, + leftCols, + leftStats.RowCount, + rightCols, + rightStats.RowCount, + )) + } // The above calculation is for inner joins. Other joins need to remove stats // that involve outer columns. @@ -967,6 +1000,27 @@ func (sb *statisticsBuilder) buildJoin( s.RowCount = leftJoinRowCount + rightJoinRowCount - innerJoinRowCount } + // Fix the stats for anti join. + switch h.joinType { + case opt.AntiJoinOp, opt.AntiJoinApplyOp: + s.RowCount = max(inputRowCount-s.RowCount, epsilon) + s.Selectivity = max(1-s.Selectivity, epsilon) + for i := 0; i < s.ColStats.Count(); i++ { + colStat := s.ColStats.Get(i) + inputColStat := sb.colStatFromChild(colStat.Cols, join, 0 /* childIdx */) + + // Distinct count is tricky for anti-joins. This is a rough estimate, + // accounting for the way distinct counts are calculated above. + colStat.DistinctCount = max( + inputColStat.DistinctCount-colStat.DistinctCount, colStat.DistinctCount, + ) + colStat.NullCount = inputColStat.NullCount - colStat.NullCount + + // TODO(rytaft): Add a method to subtract histograms from each other. + colStat.Histogram = nil + } + } + // Loop through all colSets added in this step, and adjust null counts and // distinct counts. for i := 0; i < s.ColStats.Count(); i++ { diff --git a/pkg/sql/opt/memo/testdata/stats/join b/pkg/sql/opt/memo/testdata/stats/join index 6a7752ded123..f7309a594810 100644 --- a/pkg/sql/opt/memo/testdata/stats/join +++ b/pkg/sql/opt/memo/testdata/stats/join @@ -316,17 +316,17 @@ SELECT * FROM xysd WHERE EXISTS (SELECT * FROM uv WHERE x=u) ---- semi-join (hash) ├── columns: x:1(int!null) y:2(int) s:3(string) d:4(decimal!null) - ├── stats: [rows=5000] + ├── stats: [rows=5000, distinct(1)=500, null(1)=0, distinct(4)=500, null(4)=0] ├── key: (1) ├── fd: (1)-->(2-4), (3,4)~~>(1,2) ├── scan xysd │ ├── columns: x:1(int!null) y:2(int) s:3(string) d:4(decimal!null) - │ ├── stats: [rows=5000] + │ ├── stats: [rows=5000, distinct(1)=5000, null(1)=0, distinct(4)=500, null(4)=0] │ ├── key: (1) │ └── fd: (1)-->(2-4), (3,4)~~>(1,2) ├── scan uv │ ├── columns: u:5(int) - │ └── stats: [rows=10000] + │ └── stats: [rows=10000, distinct(5)=500, null(5)=0] └── filters └── x = u [type=bool, outer=(1,5), constraints=(/1: (/NULL - ]; /5: (/NULL - ]), fd=(1)==(5), (5)==(1)] @@ -336,17 +336,17 @@ SELECT * FROM xysd WHERE NOT EXISTS (SELECT * FROM uv WHERE x=u) ---- anti-join (hash) ├── columns: x:1(int!null) y:2(int) s:3(string) d:4(decimal!null) - ├── stats: [rows=5000] + ├── stats: [rows=1e-10, distinct(1)=1e-10, null(1)=0, distinct(4)=1e-10, null(4)=0] ├── key: (1) ├── fd: (1)-->(2-4), (3,4)~~>(1,2) ├── scan xysd │ ├── columns: x:1(int!null) y:2(int) s:3(string) d:4(decimal!null) - │ ├── stats: [rows=5000] + │ ├── stats: [rows=5000, distinct(1)=5000, null(1)=0, distinct(4)=500, null(4)=0] │ ├── key: (1) │ └── fd: (1)-->(2-4), (3,4)~~>(1,2) ├── scan uv │ ├── columns: u:5(int) - │ └── stats: [rows=10000] + │ └── stats: [rows=10000, distinct(5)=500, null(5)=0] └── filters └── x = u [type=bool, outer=(1,5), constraints=(/1: (/NULL - ]; /5: (/NULL - ]), fd=(1)==(5), (5)==(1)] @@ -405,21 +405,21 @@ GROUP BY y ---- project ├── columns: count:8(int) - ├── stats: [rows=400] + ├── stats: [rows=397.482791] └── group-by ├── columns: y:2(int) count_rows:8(int) ├── grouping columns: y:2(int) - ├── stats: [rows=400, distinct(2)=400, null(2)=0] + ├── stats: [rows=397.482791, distinct(2)=397.482791, null(2)=0] ├── key: (2) ├── fd: (2)-->(8) ├── semi-join (hash) │ ├── columns: x:1(int!null) y:2(int) - │ ├── stats: [rows=5000, distinct(2)=400, null(2)=0] + │ ├── stats: [rows=1666.66667, distinct(1)=500, null(1)=0, distinct(2)=397.482791, null(2)=0] │ ├── key: (1) │ ├── fd: (1)-->(2) │ ├── scan xysd │ │ ├── columns: x:1(int!null) y:2(int) - │ │ ├── stats: [rows=5000, distinct(2)=400, null(2)=0] + │ │ ├── stats: [rows=5000, distinct(1)=5000, null(1)=0, distinct(2)=400, null(2)=0] │ │ ├── key: (1) │ │ └── fd: (1)-->(2) │ ├── scan uv @@ -439,21 +439,21 @@ GROUP BY y ---- project ├── columns: count:8(int) - ├── stats: [rows=400] + ├── stats: [rows=399.999565] └── group-by ├── columns: y:2(int) count_rows:8(int) ├── grouping columns: y:2(int) - ├── stats: [rows=400, distinct(2)=400, null(2)=0] + ├── stats: [rows=399.999565, distinct(2)=399.999565, null(2)=0] ├── key: (2) ├── fd: (2)-->(8) ├── anti-join (hash) │ ├── columns: x:1(int!null) y:2(int) - │ ├── stats: [rows=5000, distinct(2)=400, null(2)=0] + │ ├── stats: [rows=3333.33333, distinct(1)=3333.33333, null(1)=0, distinct(2)=399.999565, null(2)=0] │ ├── key: (1) │ ├── fd: (1)-->(2) │ ├── scan xysd │ │ ├── columns: x:1(int!null) y:2(int) - │ │ ├── stats: [rows=5000, distinct(2)=400, null(2)=0] + │ │ ├── stats: [rows=5000, distinct(1)=5000, null(1)=0, distinct(2)=400, null(2)=0] │ │ ├── key: (1) │ │ └── fd: (1)-->(2) │ ├── scan uv @@ -1257,3 +1257,80 @@ semi-join (lookup def) │ ├── prune: (1-3) │ └── interesting orderings: (+1,+2) └── filters (true) + +expr format=show-all colstat=5 colstat=6 colstat=(5, 6) colstat=1 colstat=2 colstat=3 colstat=(1, 2, 3) +(MakeLookupJoin + (Scan [ (Table "abc") (Cols "a,b,c") ]) + [ (JoinType "anti-join") (Table "def") (Index "def@primary") (KeyCols "a,b") (Cols "a,b,c,d,e,f") ] + [ ] +) +---- +anti-join (lookup def) + ├── columns: t.public.abc.a:1(int!null) t.public.abc.b:2(int!null) t.public.abc.c:3(int) + ├── key columns: [1 2] = [4 5] + ├── stats: [rows=1e-10, distinct(1)=1e-10, null(1)=0, distinct(2)=1e-10, null(2)=0, distinct(3)=1e-10, null(3)=1e-10, distinct(5)=1e-10, null(5)=0, distinct(6)=1e-10, null(6)=0, distinct(5,6)=1e-10, null(5,6)=0, distinct(1-3)=1e-10, null(1-3)=1e-10] + ├── cost: 506.03 + ├── key: (1,2) + ├── fd: (1,2)-->(3) + ├── interesting orderings: (+1,+2) + ├── scan t.public.abc + │ ├── columns: t.public.abc.a:1(int!null) t.public.abc.b:2(int!null) t.public.abc.c:3(int) + │ ├── stats: [rows=100, distinct(1)=100, null(1)=0, distinct(2)=10, null(2)=0, distinct(3)=10, null(3)=1, distinct(1-3)=100, null(1-3)=1] + │ ├── cost: 106.02 + │ ├── key: (1,2) + │ ├── fd: (1,2)-->(3) + │ ├── prune: (1-3) + │ └── interesting orderings: (+1,+2) + └── filters (true) + +expr format=show-all colstat=5 colstat=6 colstat=(5, 6) colstat=1 colstat=2 colstat=3 colstat=(1, 2, 3) +(MakeLookupJoin + (Scan [ (Table "abc") (Cols "a,b,c") ]) + [ (JoinType "semi-join") (Table "def") (Index "def@primary") (KeyCols "a,b") (Cols "a,b,c,d,e,f") ] + [ (False) ] +) +---- +semi-join (lookup def) + ├── columns: t.public.abc.a:1(int!null) t.public.abc.b:2(int!null) t.public.abc.c:3(int) + ├── key columns: [1 2] = [4 5] + ├── stats: [rows=0, distinct(1)=0, null(1)=0, distinct(2)=0, null(2)=0, distinct(3)=0, null(3)=0, distinct(5)=0, null(5)=0, distinct(6)=0, null(6)=0, distinct(5,6)=0, null(5,6)=0, distinct(1-3)=0, null(1-3)=0] + ├── cost: 713.04 + ├── key: (1,2) + ├── fd: (1,2)-->(3) + ├── interesting orderings: (+1,+2) + ├── scan t.public.abc + │ ├── columns: t.public.abc.a:1(int!null) t.public.abc.b:2(int!null) t.public.abc.c:3(int) + │ ├── stats: [rows=100, distinct(1)=100, null(1)=0, distinct(2)=10, null(2)=0, distinct(3)=10, null(3)=1, distinct(1-3)=100, null(1-3)=1] + │ ├── cost: 106.02 + │ ├── key: (1,2) + │ ├── fd: (1,2)-->(3) + │ ├── prune: (1-3) + │ └── interesting orderings: (+1,+2) + └── filters + └── false [type=bool] + +expr format=show-all colstat=5 colstat=6 colstat=(5, 6) colstat=1 colstat=2 colstat=3 colstat=(1, 2, 3) +(MakeLookupJoin + (Scan [ (Table "abc") (Cols "a,b,c") ]) + [ (JoinType "anti-join") (Table "def") (Index "def@primary") (KeyCols "a,b") (Cols "a,b,c,d,e,f") ] + [ (False) ] +) +---- +anti-join (lookup def) + ├── columns: t.public.abc.a:1(int!null) t.public.abc.b:2(int!null) t.public.abc.c:3(int) + ├── key columns: [1 2] = [4 5] + ├── stats: [rows=100, distinct(1)=100, null(1)=0, distinct(2)=10, null(2)=0, distinct(3)=10, null(3)=1, distinct(5)=1, null(5)=0, distinct(6)=1, null(6)=0, distinct(5,6)=1, null(5,6)=0, distinct(1-3)=100, null(1-3)=1] + ├── cost: 506.04 + ├── key: (1,2) + ├── fd: (1,2)-->(3) + ├── interesting orderings: (+1,+2) + ├── scan t.public.abc + │ ├── columns: t.public.abc.a:1(int!null) t.public.abc.b:2(int!null) t.public.abc.c:3(int) + │ ├── stats: [rows=100, distinct(1)=100, null(1)=0, distinct(2)=10, null(2)=0, distinct(3)=10, null(3)=1, distinct(1-3)=100, null(1-3)=1] + │ ├── cost: 106.02 + │ ├── key: (1,2) + │ ├── fd: (1,2)-->(3) + │ ├── prune: (1-3) + │ └── interesting orderings: (+1,+2) + └── filters + └── false [type=bool] diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch b/pkg/sql/opt/memo/testdata/stats_quality/tpch index e650f1f6452d..6b8ee060c5ea 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch @@ -4904,7 +4904,7 @@ ORDER BY sort ├── save-table-name: q16_sort_1 ├── columns: p_brand:9(char!null) p_type:10(varchar!null) p_size:11(int!null) supplier_cnt:22(int) - ├── stats: [rows=3489.49147, distinct(9)=8.33333333, null(9)=0, distinct(10)=150, null(10)=0, distinct(11)=8, null(11)=0, distinct(22)=3489.49147, null(22)=0, distinct(9-11)=3489.49147, null(9-11)=0] + ├── stats: [rows=3423.19112, distinct(9)=8.33333333, null(9)=0, distinct(10)=150, null(10)=0, distinct(11)=8, null(11)=0, distinct(22)=3423.19112, null(22)=0, distinct(9-11)=3423.19112, null(9-11)=0] ├── key: (9-11) ├── fd: (9-11)-->(22) ├── ordering: -22,+9,+10,+11 @@ -4912,13 +4912,13 @@ sort ├── save-table-name: q16_group_by_2 ├── columns: p_brand:9(char!null) p_type:10(varchar!null) p_size:11(int!null) count:22(int) ├── grouping columns: p_brand:9(char!null) p_type:10(varchar!null) p_size:11(int!null) - ├── stats: [rows=3489.49147, distinct(9)=8.33333333, null(9)=0, distinct(10)=150, null(10)=0, distinct(11)=8, null(11)=0, distinct(22)=3489.49147, null(22)=0, distinct(9-11)=3489.49147, null(9-11)=0] + ├── stats: [rows=3423.19112, distinct(9)=8.33333333, null(9)=0, distinct(10)=150, null(10)=0, distinct(11)=8, null(11)=0, distinct(22)=3423.19112, null(22)=0, distinct(9-11)=3423.19112, null(9-11)=0] ├── key: (9-11) ├── fd: (9-11)-->(22) ├── inner-join (hash) │ ├── save-table-name: q16_inner_join_3 │ ├── columns: ps_partkey:1(int!null) ps_suppkey:2(int!null) p_partkey:6(int!null) p_brand:9(char!null) p_type:10(varchar!null) p_size:11(int!null) - │ ├── stats: [rows=14276.4012, distinct(1)=3555.43444, null(1)=0, distinct(2)=7567.69437, null(2)=0, distinct(6)=3555.43444, null(6)=0, distinct(9)=8.33333333, null(9)=0, distinct(10)=150, null(10)=0, distinct(11)=8, null(11)=0, distinct(9-11)=3489.49147, null(9-11)=0] + │ ├── stats: [rows=11748.5068, distinct(1)=3555.43444, null(1)=0, distinct(2)=5482.69133, null(2)=0, distinct(6)=3555.43444, null(6)=0, distinct(9)=8.33333333, null(9)=0, distinct(10)=150, null(10)=0, distinct(11)=8, null(11)=0, distinct(9-11)=3423.19112, null(9-11)=0] │ ├── key: (2,6) │ ├── fd: (6)-->(9-11), (1)==(6), (6)==(1) │ ├── anti-join (merge) @@ -4926,7 +4926,7 @@ sort │ │ ├── columns: ps_partkey:1(int!null) ps_suppkey:2(int!null) │ │ ├── left ordering: +2 │ │ ├── right ordering: +15 - │ │ ├── stats: [rows=800000, distinct(1)=199241, null(1)=0, distinct(2)=9920, null(2)=0] + │ │ ├── stats: [rows=531182.796, distinct(1)=160756.595, null(1)=0, distinct(2)=6591.74384, null(2)=0] │ │ ├── key: (1,2) │ │ ├── scan partsupp@ps_sk │ │ │ ├── save-table-name: q16_scan_5 @@ -4991,10 +4991,10 @@ column_names row_count distinct_count null_count {supplier_cnt} 18314 15 0 ~~~~ column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{p_brand} 3489.00 5.25 <== 8.00 3.00 <== 0.00 1.00 -{p_size} 3489.00 5.25 <== 8.00 1.00 0.00 1.00 -{p_type} 3489.00 5.25 <== 150.00 1.03 0.00 1.00 -{supplier_cnt} 3489.00 5.25 <== 3489.00 232.60 <== 0.00 1.00 +{p_brand} 3423.00 5.35 <== 8.00 3.00 <== 0.00 1.00 +{p_size} 3423.00 5.35 <== 8.00 1.00 0.00 1.00 +{p_type} 3423.00 5.35 <== 150.00 1.03 0.00 1.00 +{supplier_cnt} 3423.00 5.35 <== 3423.00 228.20 <== 0.00 1.00 stats table=q16_group_by_2 ---- @@ -5005,10 +5005,10 @@ column_names row_count distinct_count null_count {count} 18314 15 0 ~~~~ column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{count} 3489.00 5.25 <== 3489.00 232.60 <== 0.00 1.00 -{p_brand} 3489.00 5.25 <== 8.00 3.00 <== 0.00 1.00 -{p_size} 3489.00 5.25 <== 8.00 1.00 0.00 1.00 -{p_type} 3489.00 5.25 <== 150.00 1.03 0.00 1.00 +{count} 3423.00 5.35 <== 3423.00 228.20 <== 0.00 1.00 +{p_brand} 3423.00 5.35 <== 8.00 3.00 <== 0.00 1.00 +{p_size} 3423.00 5.35 <== 8.00 1.00 0.00 1.00 +{p_type} 3423.00 5.35 <== 150.00 1.03 0.00 1.00 stats table=q16_inner_join_3 ---- @@ -5021,12 +5021,12 @@ column_names row_count distinct_count null_count {ps_suppkey} 118274 9916 0 ~~~~ column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{p_brand} 14276.00 8.28 <== 8.00 3.00 <== 0.00 1.00 -{p_partkey} 14276.00 8.28 <== 3555.00 8.28 <== 0.00 1.00 -{p_size} 14276.00 8.28 <== 8.00 1.00 0.00 1.00 -{p_type} 14276.00 8.28 <== 150.00 1.03 0.00 1.00 -{ps_partkey} 14276.00 8.28 <== 3555.00 8.28 <== 0.00 1.00 -{ps_suppkey} 14276.00 8.28 <== 7568.00 1.31 0.00 1.00 +{p_brand} 11749.00 10.07 <== 8.00 3.00 <== 0.00 1.00 +{p_partkey} 11749.00 10.07 <== 3555.00 8.28 <== 0.00 1.00 +{p_size} 11749.00 10.07 <== 8.00 1.00 0.00 1.00 +{p_type} 11749.00 10.07 <== 150.00 1.03 0.00 1.00 +{ps_partkey} 11749.00 10.07 <== 3555.00 8.28 <== 0.00 1.00 +{ps_suppkey} 11749.00 10.07 <== 5483.00 1.81 0.00 1.00 stats table=q16_merge_join_4 ---- @@ -5035,8 +5035,8 @@ column_names row_count distinct_count null_count {ps_suppkey} 799680 9916 0 ~~~~ column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{ps_partkey} 800000.00 1.00 199241.00 1.00 0.00 1.00 -{ps_suppkey} 800000.00 1.00 9920.00 1.00 0.00 1.00 +{ps_partkey} 531183.00 1.51 160757.00 1.24 0.00 1.00 +{ps_suppkey} 531183.00 1.51 6592.00 1.50 0.00 1.00 stats table=q16_scan_5 ---- @@ -5407,7 +5407,7 @@ limit ├── sort │ ├── save-table-name: q18_sort_2 │ ├── columns: c_custkey:1(int) c_name:2(varchar) o_orderkey:9(int!null) o_totalprice:12(float) o_orderdate:13(date) sum:51(float) - │ ├── stats: [rows=1471426.19, distinct(1)=1471426.19, null(1)=0, distinct(2)=1471426.19, null(2)=0, distinct(9)=1471426.19, null(9)=0, distinct(12)=1471426.19, null(12)=0, distinct(13)=1471426.19, null(13)=0, distinct(51)=1471426.19, null(51)=0] + │ ├── stats: [rows=499392.239, distinct(1)=499392.239, null(1)=0, distinct(2)=499392.239, null(2)=0, distinct(9)=499392.239, null(9)=0, distinct(12)=499392.239, null(12)=0, distinct(13)=499392.239, null(13)=0, distinct(51)=499392.239, null(51)=0] │ ├── key: (9) │ ├── fd: (1)-->(2), (9)-->(1,2,12,13,51) │ ├── ordering: -12,+13 @@ -5415,36 +5415,30 @@ limit │ ├── save-table-name: q18_group_by_3 │ ├── columns: c_custkey:1(int) c_name:2(varchar) o_orderkey:9(int!null) o_totalprice:12(float) o_orderdate:13(date) sum:51(float) │ ├── grouping columns: o_orderkey:9(int!null) - │ ├── stats: [rows=1471426.19, distinct(1)=1471426.19, null(1)=0, distinct(2)=1471426.19, null(2)=0, distinct(9)=1471426.19, null(9)=0, distinct(12)=1471426.19, null(12)=0, distinct(13)=1471426.19, null(13)=0, distinct(51)=1471426.19, null(51)=0] + │ ├── stats: [rows=499392.239, distinct(1)=499392.239, null(1)=0, distinct(2)=499392.239, null(2)=0, distinct(9)=499392.239, null(9)=0, distinct(12)=499392.239, null(12)=0, distinct(13)=499392.239, null(13)=0, distinct(51)=499392.239, null(51)=0] │ ├── key: (9) │ ├── fd: (1)-->(2), (9)-->(1,2,12,13,51) │ ├── inner-join (hash) │ │ ├── save-table-name: q18_inner_join_4 │ │ ├── columns: c_custkey:1(int!null) c_name:2(varchar!null) o_orderkey:9(int!null) o_custkey:10(int!null) o_totalprice:12(float!null) o_orderdate:13(date!null) l_orderkey:18(int!null) l_quantity:22(float!null) - │ │ ├── stats: [rows=5941074.68, distinct(1)=99846, null(1)=0, distinct(2)=150000, null(2)=0, distinct(9)=1471426.19, null(9)=0, distinct(10)=99846, null(10)=0, distinct(12)=1410750.85, null(12)=0, distinct(13)=2406, null(13)=0, distinct(18)=1471426.19, null(18)=0, distinct(22)=50, null(22)=0] + │ │ ├── stats: [rows=2016361.14, distinct(1)=99649.071, null(1)=0, distinct(2)=149999.782, null(2)=0, distinct(9)=499392.239, null(9)=0, distinct(10)=99649.071, null(10)=0, distinct(12)=488043.529, null(12)=0, distinct(13)=2406, null(13)=0, distinct(18)=499392.239, null(18)=0, distinct(22)=50, null(22)=0] │ │ ├── fd: (1)-->(2), (9)-->(10,12,13), (9)==(18), (18)==(9), (1)==(10), (10)==(1) - │ │ ├── scan lineitem - │ │ │ ├── save-table-name: q18_scan_5 - │ │ │ ├── columns: l_orderkey:18(int!null) l_quantity:22(float!null) - │ │ │ └── stats: [rows=6001215, distinct(18)=1527270, null(18)=0, distinct(22)=50, null(22)=0] - │ │ │ histogram(18)= 0 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 - │ │ │ <--- 326 ------- 28929 ------- 50503 ------- 89793 ------- 115938 ------- 146944 ------- 176768 ------- 211201 ------- 237860 ------- 266885 ------- 297604 ------- 330021 ------- 365889 ------- 398951 ------- 426117 ------- 451328 ------- 472134 ------- 499590 ------- 529284 ------- 557254 ------- 589154 ------- 619394 ------- 642951 ------- 670113 ------- 692931 ------- 721157 ------- 751687 ------- 777766 ------- 804582 ------- 836740 ------- 868868 ------- 898912 ------- 922500 ------- 946403 ------- 984870 ------- 1007936 ------- 1030117 ------- 1062275 ------- 1093572 ------- 1120709 ------- 1150981 ------- 1182786 ------- 1206406 ------- 1234116 ------- 1260961 ------- 1290502 ------- 1329510 ------- 1355426 ------- 1381313 ------- 1409796 ------- 1445254 ------- 1479233 ------- 1504935 ------- 1531079 ------- 1559650 ------- 1583616 ------- 1617504 ------- 1655749 ------- 1685185 ------- 1718183 ------- 1747716 ------- 1772131 ------- 1802372 ------- 1833315 ------- 1862403 ------- 1897894 ------- 1922819 ------- 1954405 ------- 1979329 ------- 2009859 ------- 2041670 ------- 2070851 ------- 2093828 ------- 2127973 ------- 2167777 ------- 2194883 ------- 2227814 ------- 2262437 ------- 2296353 ------- 2321024 ------- 2346051 ------- 2376257 ------- 2404932 ------- 2446273 ------- 2474081 ------- 2504515 ------- 2535302 ------- 2561413 ------- 2592737 ------- 2616801 ------- 2646112 ------- 2676546 ------- 2702116 ------- 2732454 ------- 2765382 ------- 2799495 ------- 2828866 ------- 2868737 ------- 2910625 ------- 2938464 ------- 2963140 ------- 3003302 ------- 3043264 ------- 3069123 ------- 3095909 ------- 3126693 ------- 3160485 ------- 3196039 ------- 3229504 ------- 3259712 ------- 3286439 ------- 3318852 ------- 3346821 ------- 3370119 ------- 3395204 ------- 3425888 ------- 3448611 ------- 3476130 ------- 3502372 ------- 3529474 ------- 3556390 ------- 3583553 ------- 3612550 ------- 3647875 ------- 3679140 ------- 3702661 ------- 3738017 ------- 3778050 ------- 3806114 ------- 3839074 ------- 3872805 ------- 3905697 ------- 3926212 ------- 3959841 ------- 3997281 ------- 4033861 ------- 4063591 ------- 4097831 ------- 4124807 ------- 4158656 ------- 4195748 ------- 4234274 ------- 4269952 ------- 4298949 ------- 4332806 ------- 4364705 ------- 4398246 ------- 4430695 ------- 4466403 ------- 4494662 ------- 4524420 ------- 4558561 ------- 4601092 ------- 4632871 ------- 4658694 ------- 4690501 ------- 4728066 ------- 4758657 ------- 4788294 ------- 4818597 ------- 4855874 ------- 4890913 ------- 4915366 ------- 4940709 ------- 4972357 ------- 4995298 ------- 5019523 ------- 5043329 ------- 5077376 ------- 5109920 ------- 5136582 ------- 5161152 ------- 5191846 ------- 5219973 ------- 5251015 ------- 5282021 ------- 5312355 ------- 5343207 ------- 5381318 ------- 5416163 ------- 5445382 ------- 5476933 ------- 5509185 ------- 5539237 ------- 5566818 ------- 5588739 ------- 5620481 ------- 5644001 ------- 5667010 ------- 5689476 ------- 5724709 ------- 5755398 ------- 5790598 ------- 5819425 ------- 5846341 ------- 5874656 ------- 5908067 ------- 5933572 ------- 5962659 ------- 5999971 - │ │ ├── inner-join (hash) - │ │ │ ├── save-table-name: q18_inner_join_6 - │ │ │ ├── columns: c_custkey:1(int!null) c_name:2(varchar!null) o_orderkey:9(int!null) o_custkey:10(int!null) o_totalprice:12(float!null) o_orderdate:13(date!null) - │ │ │ ├── stats: [rows=1511964.68, distinct(1)=99846, null(1)=0, distinct(2)=149993.712, null(2)=0, distinct(9)=952566.744, null(9)=0, distinct(10)=99846, null(10)=0, distinct(12)=941447.245, null(12)=0, distinct(13)=2406, null(13)=0] - │ │ │ ├── key: (9) - │ │ │ ├── fd: (9)-->(10,12,13), (1)-->(2), (1)==(10), (10)==(1) + │ │ ├── inner-join (lookup lineitem) + │ │ │ ├── save-table-name: q18_lookup_join_5 + │ │ │ ├── columns: o_orderkey:9(int!null) o_custkey:10(int!null) o_totalprice:12(float!null) o_orderdate:13(date!null) l_orderkey:18(int!null) l_quantity:22(float!null) + │ │ │ ├── key columns: [9] = [18] + │ │ │ ├── stats: [rows=2000405, distinct(9)=509090, null(9)=0, distinct(10)=99649.071, null(10)=0, distinct(12)=496607.042, null(12)=0, distinct(13)=2406, null(13)=0, distinct(18)=509090, null(18)=0, distinct(22)=50, null(22)=0] + │ │ │ ├── fd: (9)-->(10,12,13), (9)==(18), (18)==(9) │ │ │ ├── semi-join (merge) - │ │ │ │ ├── save-table-name: q18_merge_join_7 + │ │ │ │ ├── save-table-name: q18_merge_join_6 │ │ │ │ ├── columns: o_orderkey:9(int!null) o_custkey:10(int!null) o_totalprice:12(float!null) o_orderdate:13(date!null) │ │ │ │ ├── left ordering: +9 │ │ │ │ ├── right ordering: +34 - │ │ │ │ ├── stats: [rows=1500000, distinct(9)=1500000, null(9)=0, distinct(10)=99846, null(10)=0, distinct(12)=1459167, null(12)=0, distinct(13)=2406, null(13)=0] + │ │ │ │ ├── stats: [rows=509090, distinct(9)=509090, null(9)=0, distinct(10)=99649.0712, null(10)=0, distinct(12)=506350.486, null(12)=0, distinct(13)=2406, null(13)=0] │ │ │ │ ├── key: (9) │ │ │ │ ├── fd: (9)-->(10,12,13) │ │ │ │ ├── scan orders - │ │ │ │ │ ├── save-table-name: q18_scan_8 + │ │ │ │ │ ├── save-table-name: q18_scan_7 │ │ │ │ │ ├── columns: o_orderkey:9(int!null) o_custkey:10(int!null) o_totalprice:12(float!null) o_orderdate:13(date!null) │ │ │ │ │ ├── stats: [rows=1500000, distinct(9)=1500000, null(9)=0, distinct(10)=99846, null(10)=0, distinct(12)=1459167, null(12)=0, distinct(13)=2406, null(13)=0] │ │ │ │ │ │ histogram(9)= 0 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7350 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 7500 150 @@ -5457,14 +5451,14 @@ limit │ │ │ │ │ ├── fd: (9)-->(10,12,13) │ │ │ │ │ └── ordering: +9 │ │ │ │ ├── select - │ │ │ │ │ ├── save-table-name: q18_select_9 + │ │ │ │ │ ├── save-table-name: q18_select_8 │ │ │ │ │ ├── columns: l_orderkey:34(int!null) sum:50(float!null) │ │ │ │ │ ├── stats: [rows=509090, distinct(34)=509090, null(34)=0, distinct(50)=509090, null(50)=0] │ │ │ │ │ ├── key: (34) │ │ │ │ │ ├── fd: (34)-->(50) │ │ │ │ │ ├── ordering: +34 │ │ │ │ │ ├── group-by - │ │ │ │ │ │ ├── save-table-name: q18_group_by_10 + │ │ │ │ │ │ ├── save-table-name: q18_group_by_9 │ │ │ │ │ │ ├── columns: l_orderkey:34(int!null) sum:50(float) │ │ │ │ │ │ ├── grouping columns: l_orderkey:34(int!null) │ │ │ │ │ │ ├── stats: [rows=1527270, distinct(34)=1527270, null(34)=0, distinct(50)=1527270, null(50)=0] @@ -5472,7 +5466,7 @@ limit │ │ │ │ │ │ ├── fd: (34)-->(50) │ │ │ │ │ │ ├── ordering: +34 │ │ │ │ │ │ ├── scan lineitem - │ │ │ │ │ │ │ ├── save-table-name: q18_scan_11 + │ │ │ │ │ │ │ ├── save-table-name: q18_scan_10 │ │ │ │ │ │ │ ├── columns: l_orderkey:34(int!null) l_quantity:38(float!null) │ │ │ │ │ │ │ ├── stats: [rows=6001215, distinct(34)=1527270, null(34)=0, distinct(38)=50, null(38)=0] │ │ │ │ │ │ │ │ histogram(34)= 0 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 29405 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 30006 600 @@ -5484,18 +5478,17 @@ limit │ │ │ │ │ └── filters │ │ │ │ │ └── sum > 300.0 [type=bool, outer=(50), constraints=(/50: [/300.00000000000006 - ]; tight)] │ │ │ │ └── filters (true) - │ │ │ ├── scan customer - │ │ │ │ ├── save-table-name: q18_scan_12 - │ │ │ │ ├── columns: c_custkey:1(int!null) c_name:2(varchar!null) - │ │ │ │ ├── stats: [rows=150000, distinct(1)=148813, null(1)=0, distinct(2)=150000, null(2)=0] - │ │ │ │ │ histogram(1)= 0 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 - │ │ │ │ │ <--- 2 ----- 776 ----- 1422 ----- 2189 ----- 2973 ----- 3583 ----- 4390 ----- 5154 ----- 5962 ----- 6965 ----- 7596 ----- 8303 ----- 9167 ----- 9833 ----- 10695 ----- 11397 ----- 11979 ----- 12651 ----- 13397 ----- 14144 ----- 14951 ----- 15698 ----- 16460 ----- 17203 ----- 17846 ----- 18462 ----- 19390 ----- 20189 ----- 20852 ----- 21642 ----- 22379 ----- 23009 ----- 23856 ----- 24734 ----- 25473 ----- 26231 ----- 26978 ----- 27654 ----- 28276 ----- 29054 ----- 29727 ----- 30527 ----- 31177 ----- 32126 ----- 32984 ----- 33684 ----- 34316 ----- 35070 ----- 35703 ----- 36397 ----- 37156 ----- 37709 ----- 38488 ----- 39131 ----- 39740 ----- 40736 ----- 41459 ----- 42388 ----- 42999 ----- 43844 ----- 44571 ----- 45428 ----- 46283 ----- 46979 ----- 47712 ----- 48708 ----- 49487 ----- 50275 ----- 51131 ----- 51836 ----- 52652 ----- 53389 ----- 54179 ----- 54861 ----- 55609 ----- 56492 ----- 57284 ----- 57917 ----- 58793 ----- 59665 ----- 60285 ----- 60840 ----- 61523 ----- 62354 ----- 63178 ----- 63933 ----- 64642 ----- 65282 ----- 65864 ----- 66755 ----- 67407 ----- 68099 ----- 68875 ----- 69638 ----- 70304 ----- 71016 ----- 71830 ----- 72742 ----- 73590 ----- 74434 ----- 75274 ----- 75861 ----- 76547 ----- 77252 ----- 77978 ----- 78650 ----- 79313 ----- 79925 ----- 80677 ----- 81497 ----- 82205 ----- 82962 ----- 83879 ----- 84815 ----- 85521 ----- 86272 ----- 87140 ----- 87759 ----- 88634 ----- 89452 ----- 90192 ----- 90920 ----- 91756 ----- 92690 ----- 93299 ----- 93950 ----- 94812 ----- 95569 ----- 96295 ----- 96904 ----- 97499 ----- 98144 ----- 98764 ----- 99582 ----- 100453 ----- 101098 ----- 101892 ----- 102700 ----- 103419 ----- 104297 ----- 105040 ----- 105864 ----- 106498 ----- 107196 ----- 108022 ----- 108731 ----- 109398 ----- 110145 ----- 110849 ----- 111758 ----- 112501 ----- 113222 ----- 114019 ----- 114904 ----- 115693 ----- 116350 ----- 116955 ----- 117581 ----- 118366 ----- 119159 ----- 119902 ----- 120535 ----- 121321 ----- 121993 ----- 122769 ----- 123504 ----- 124225 ----- 124992 ----- 125632 ----- 126685 ----- 127641 ----- 128303 ----- 129042 ----- 129589 ----- 130548 ----- 131374 ----- 132325 ----- 133042 ----- 133883 ----- 134716 ----- 135520 ----- 136173 ----- 136858 ----- 137584 ----- 138381 ----- 139162 ----- 139923 ----- 140738 ----- 141557 ----- 142287 ----- 143002 ----- 143794 ----- 144420 ----- 145276 ----- 146100 ----- 146977 ----- 147821 ----- 148440 ----- 149247 ----- 149978 - │ │ │ │ ├── key: (1) - │ │ │ │ └── fd: (1)-->(2) - │ │ │ └── filters - │ │ │ └── c_custkey = o_custkey [type=bool, outer=(1,10), constraints=(/1: (/NULL - ]; /10: (/NULL - ]), fd=(1)==(10), (10)==(1)] + │ │ │ └── filters (true) + │ │ ├── scan customer + │ │ │ ├── save-table-name: q18_scan_11 + │ │ │ ├── columns: c_custkey:1(int!null) c_name:2(varchar!null) + │ │ │ ├── stats: [rows=150000, distinct(1)=148813, null(1)=0, distinct(2)=150000, null(2)=0] + │ │ │ │ histogram(1)= 0 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 + │ │ │ │ <--- 2 ----- 776 ----- 1422 ----- 2189 ----- 2973 ----- 3583 ----- 4390 ----- 5154 ----- 5962 ----- 6965 ----- 7596 ----- 8303 ----- 9167 ----- 9833 ----- 10695 ----- 11397 ----- 11979 ----- 12651 ----- 13397 ----- 14144 ----- 14951 ----- 15698 ----- 16460 ----- 17203 ----- 17846 ----- 18462 ----- 19390 ----- 20189 ----- 20852 ----- 21642 ----- 22379 ----- 23009 ----- 23856 ----- 24734 ----- 25473 ----- 26231 ----- 26978 ----- 27654 ----- 28276 ----- 29054 ----- 29727 ----- 30527 ----- 31177 ----- 32126 ----- 32984 ----- 33684 ----- 34316 ----- 35070 ----- 35703 ----- 36397 ----- 37156 ----- 37709 ----- 38488 ----- 39131 ----- 39740 ----- 40736 ----- 41459 ----- 42388 ----- 42999 ----- 43844 ----- 44571 ----- 45428 ----- 46283 ----- 46979 ----- 47712 ----- 48708 ----- 49487 ----- 50275 ----- 51131 ----- 51836 ----- 52652 ----- 53389 ----- 54179 ----- 54861 ----- 55609 ----- 56492 ----- 57284 ----- 57917 ----- 58793 ----- 59665 ----- 60285 ----- 60840 ----- 61523 ----- 62354 ----- 63178 ----- 63933 ----- 64642 ----- 65282 ----- 65864 ----- 66755 ----- 67407 ----- 68099 ----- 68875 ----- 69638 ----- 70304 ----- 71016 ----- 71830 ----- 72742 ----- 73590 ----- 74434 ----- 75274 ----- 75861 ----- 76547 ----- 77252 ----- 77978 ----- 78650 ----- 79313 ----- 79925 ----- 80677 ----- 81497 ----- 82205 ----- 82962 ----- 83879 ----- 84815 ----- 85521 ----- 86272 ----- 87140 ----- 87759 ----- 88634 ----- 89452 ----- 90192 ----- 90920 ----- 91756 ----- 92690 ----- 93299 ----- 93950 ----- 94812 ----- 95569 ----- 96295 ----- 96904 ----- 97499 ----- 98144 ----- 98764 ----- 99582 ----- 100453 ----- 101098 ----- 101892 ----- 102700 ----- 103419 ----- 104297 ----- 105040 ----- 105864 ----- 106498 ----- 107196 ----- 108022 ----- 108731 ----- 109398 ----- 110145 ----- 110849 ----- 111758 ----- 112501 ----- 113222 ----- 114019 ----- 114904 ----- 115693 ----- 116350 ----- 116955 ----- 117581 ----- 118366 ----- 119159 ----- 119902 ----- 120535 ----- 121321 ----- 121993 ----- 122769 ----- 123504 ----- 124225 ----- 124992 ----- 125632 ----- 126685 ----- 127641 ----- 128303 ----- 129042 ----- 129589 ----- 130548 ----- 131374 ----- 132325 ----- 133042 ----- 133883 ----- 134716 ----- 135520 ----- 136173 ----- 136858 ----- 137584 ----- 138381 ----- 139162 ----- 139923 ----- 140738 ----- 141557 ----- 142287 ----- 143002 ----- 143794 ----- 144420 ----- 145276 ----- 146100 ----- 146977 ----- 147821 ----- 148440 ----- 149247 ----- 149978 + │ │ │ ├── key: (1) + │ │ │ └── fd: (1)-->(2) │ │ └── filters - │ │ └── o_orderkey = l_orderkey [type=bool, outer=(9,18), constraints=(/9: (/NULL - ]; /18: (/NULL - ]), fd=(9)==(18), (18)==(9)] + │ │ └── c_custkey = o_custkey [type=bool, outer=(1,10), constraints=(/1: (/NULL - ]; /10: (/NULL - ]), fd=(1)==(10), (10)==(1)] │ └── aggregations │ ├── sum [type=float, outer=(22)] │ │ └── variable: l_quantity [type=float] @@ -5511,175 +5504,36 @@ limit stats table=q18_limit_1 ---- -column_names row_count distinct_count null_count -{c_custkey} 57 57 0 -{c_name} 57 57 0 -{o_orderdate} 57 57 0 -{o_orderkey} 57 57 0 -{o_totalprice} 57 57 0 -{sum} 57 18 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{c_custkey} 100.00 1.75 100.00 1.75 0.00 1.00 -{c_name} 100.00 1.75 100.00 1.75 0.00 1.00 -{o_orderdate} 100.00 1.75 100.00 1.75 0.00 1.00 -{o_orderkey} 100.00 1.75 100.00 1.75 0.00 1.00 -{o_totalprice} 100.00 1.75 100.00 1.75 0.00 1.00 -{sum} 100.00 1.75 100.00 5.56 <== 0.00 1.00 stats table=q18_sort_2 ---- -column_names row_count distinct_count null_count -{c_custkey} 57 57 0 -{c_name} 57 57 0 -{o_orderdate} 57 57 0 -{o_orderkey} 57 57 0 -{o_totalprice} 57 57 0 -{sum} 57 18 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{c_custkey} 1471426.00 25814.49 <== 1471426.00 25814.49 <== 0.00 1.00 -{c_name} 1471426.00 25814.49 <== 1471426.00 25814.49 <== 0.00 1.00 -{o_orderdate} 1471426.00 25814.49 <== 1471426.00 25814.49 <== 0.00 1.00 -{o_orderkey} 1471426.00 25814.49 <== 1471426.00 25814.49 <== 0.00 1.00 -{o_totalprice} 1471426.00 25814.49 <== 1471426.00 25814.49 <== 0.00 1.00 -{sum} 1471426.00 25814.49 <== 1471426.00 81745.89 <== 0.00 1.00 stats table=q18_group_by_3 ---- -column_names row_count distinct_count null_count -{c_custkey} 57 57 0 -{c_name} 57 57 0 -{o_orderdate} 57 57 0 -{o_orderkey} 57 57 0 -{o_totalprice} 57 57 0 -{sum} 57 18 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{c_custkey} 1471426.00 25814.49 <== 1471426.00 25814.49 <== 0.00 1.00 -{c_name} 1471426.00 25814.49 <== 1471426.00 25814.49 <== 0.00 1.00 -{o_orderdate} 1471426.00 25814.49 <== 1471426.00 25814.49 <== 0.00 1.00 -{o_orderkey} 1471426.00 25814.49 <== 1471426.00 25814.49 <== 0.00 1.00 -{o_totalprice} 1471426.00 25814.49 <== 1471426.00 25814.49 <== 0.00 1.00 -{sum} 1471426.00 25814.49 <== 1471426.00 81745.89 <== 0.00 1.00 stats table=q18_inner_join_4 ---- -column_names row_count distinct_count null_count -{c_custkey} 399 57 0 -{c_name} 399 57 0 -{l_orderkey} 399 57 0 -{l_quantity} 399 27 0 -{o_custkey} 399 57 0 -{o_orderdate} 399 57 0 -{o_orderkey} 399 57 0 -{o_totalprice} 399 57 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{c_custkey} 5941075.00 14889.91 <== 99846.00 1751.68 <== 0.00 1.00 -{c_name} 5941075.00 14889.91 <== 150000.00 2631.58 <== 0.00 1.00 -{l_orderkey} 5941075.00 14889.91 <== 1471426.00 25814.49 <== 0.00 1.00 -{l_quantity} 5941075.00 14889.91 <== 50.00 1.85 0.00 1.00 -{o_custkey} 5941075.00 14889.91 <== 99846.00 1751.68 <== 0.00 1.00 -{o_orderdate} 5941075.00 14889.91 <== 2406.00 42.21 <== 0.00 1.00 -{o_orderkey} 5941075.00 14889.91 <== 1471426.00 25814.49 <== 0.00 1.00 -{o_totalprice} 5941075.00 14889.91 <== 1410751.00 24750.02 <== 0.00 1.00 -stats table=q18_scan_5 +stats table=q18_lookup_join_5 ---- -column_names row_count distinct_count null_count -{l_orderkey} 6001215 1527270 0 -{l_quantity} 6001215 50 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{l_orderkey} 6001215.00 1.00 1527270.00 1.00 0.00 1.00 -{l_quantity} 6001215.00 1.00 50.00 1.00 0.00 1.00 -stats table=q18_inner_join_6 +stats table=q18_merge_join_6 ---- -column_names row_count distinct_count null_count -{c_custkey} 57 57 0 -{c_name} 57 57 0 -{o_custkey} 57 57 0 -{o_orderdate} 57 57 0 -{o_orderkey} 57 57 0 -{o_totalprice} 57 57 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{c_custkey} 1511965.00 26525.70 <== 99846.00 1751.68 <== 0.00 1.00 -{c_name} 1511965.00 26525.70 <== 149994.00 2631.47 <== 0.00 1.00 -{o_custkey} 1511965.00 26525.70 <== 99846.00 1751.68 <== 0.00 1.00 -{o_orderdate} 1511965.00 26525.70 <== 2406.00 42.21 <== 0.00 1.00 -{o_orderkey} 1511965.00 26525.70 <== 952567.00 16711.70 <== 0.00 1.00 -{o_totalprice} 1511965.00 26525.70 <== 941447.00 16516.61 <== 0.00 1.00 -stats table=q18_merge_join_7 +stats table=q18_scan_7 ---- -column_names row_count distinct_count null_count -{o_custkey} 57 57 0 -{o_orderdate} 57 57 0 -{o_orderkey} 57 57 0 -{o_totalprice} 57 57 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{o_custkey} 1500000.00 26315.79 <== 99846.00 1751.68 <== 0.00 1.00 -{o_orderdate} 1500000.00 26315.79 <== 2406.00 42.21 <== 0.00 1.00 -{o_orderkey} 1500000.00 26315.79 <== 1500000.00 26315.79 <== 0.00 1.00 -{o_totalprice} 1500000.00 26315.79 <== 1459167.00 25599.42 <== 0.00 1.00 -stats table=q18_scan_8 +stats table=q18_select_8 ---- -column_names row_count distinct_count null_count -{o_custkey} 1500000 99846 0 -{o_orderdate} 1500000 2406 0 -{o_orderkey} 1500000 1527270 0 -{o_totalprice} 1500000 1459167 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{o_custkey} 1500000.00 1.00 99846.00 1.00 0.00 1.00 -{o_orderdate} 1500000.00 1.00 2406.00 1.00 0.00 1.00 -{o_orderkey} 1500000.00 1.00 1500000.00 1.02 0.00 1.00 -{o_totalprice} 1500000.00 1.00 1459167.00 1.00 0.00 1.00 -stats table=q18_select_9 +stats table=q18_group_by_9 ---- -column_names row_count distinct_count null_count -{l_orderkey} 57 57 0 -{sum} 57 18 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{l_orderkey} 509090.00 8931.40 <== 509090.00 8931.40 <== 0.00 1.00 -{sum} 509090.00 8931.40 <== 509090.00 28282.78 <== 0.00 1.00 -stats table=q18_group_by_10 +stats table=q18_scan_10 ---- -column_names row_count distinct_count null_count -{l_orderkey} 1500000 1527270 0 -{sum} 1500000 318 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{l_orderkey} 1527270.00 1.02 1527270.00 1.00 0.00 1.00 -{sum} 1527270.00 1.02 1527270.00 4802.74 <== 0.00 1.00 stats table=q18_scan_11 ---- -column_names row_count distinct_count null_count -{l_orderkey} 6001215 1527270 0 -{l_quantity} 6001215 50 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{l_orderkey} 6001215.00 1.00 1527270.00 1.00 0.00 1.00 -{l_quantity} 6001215.00 1.00 50.00 1.00 0.00 1.00 - -stats table=q18_scan_12 ----- -column_names row_count distinct_count null_count -{c_custkey} 150000 148813 0 -{c_name} 150000 151126 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{c_custkey} 150000.00 1.00 148813.00 1.00 0.00 1.00 -{c_name} 150000.00 1.00 150000.00 1.01 0.00 1.00 # -------------------------------------------------- # Q19 @@ -5956,13 +5810,13 @@ sort └── inner-join (hash) ├── save-table-name: q20_inner_join_3 ├── columns: s_suppkey:1(int!null) s_name:2(char!null) s_address:3(varchar!null) s_nationkey:4(int!null) n_nationkey:8(int!null) n_name:9(char!null) - ├── stats: [rows=400, distinct(1)=399.934613, null(1)=0, distinct(2)=399.991883, null(2)=0, distinct(3)=400, null(3)=0, distinct(4)=1, null(4)=0, distinct(8)=1, null(8)=0, distinct(9)=1, null(9)=0] + ├── stats: [rows=400, distinct(1)=399.784674, null(1)=0, distinct(2)=399.991883, null(2)=0, distinct(3)=400, null(3)=0, distinct(4)=1, null(4)=0, distinct(8)=1, null(8)=0, distinct(9)=1, null(9)=0] ├── key: (1) ├── fd: ()-->(9), (1)-->(2-4), (4)==(8), (8)==(4) ├── semi-join (hash) │ ├── save-table-name: q20_semi_join_4 │ ├── columns: s_suppkey:1(int!null) s_name:2(char!null) s_address:3(varchar!null) s_nationkey:4(int!null) - │ ├── stats: [rows=10000, distinct(1)=9920, null(1)=0, distinct(2)=9990, null(2)=0, distinct(3)=10000, null(3)=0, distinct(4)=25, null(4)=0] + │ ├── stats: [rows=10000, distinct(1)=9741.23343, null(1)=0, distinct(2)=9990, null(2)=0, distinct(3)=10000, null(3)=0, distinct(4)=25, null(4)=0] │ ├── key: (1) │ ├── fd: (1)-->(2-4) │ ├── scan supplier @@ -5978,7 +5832,7 @@ sort │ ├── project │ │ ├── save-table-name: q20_project_6 │ │ ├── columns: ps_partkey:12(int!null) ps_suppkey:13(int!null) - │ │ ├── stats: [rows=266666.667, distinct(12)=160127.162, null(12)=0, distinct(13)=9920, null(13)=0] + │ │ ├── stats: [rows=37007.6247, distinct(12)=22217.3354, null(12)=0, distinct(13)=9741.23343, null(13)=0] │ │ ├── key: (12,13) │ │ └── project │ │ ├── save-table-name: q20_project_7 @@ -6134,7 +5988,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_ {s_address} 10000.00 2.27 <== 10000.00 2.29 <== 0.00 1.00 {s_name} 10000.00 2.27 <== 9990.00 2.28 <== 0.00 1.00 {s_nationkey} 10000.00 2.27 <== 25.00 1.00 0.00 1.00 -{s_suppkey} 10000.00 2.27 <== 9920.00 2.24 <== 0.00 1.00 +{s_suppkey} 10000.00 2.27 <== 9741.00 2.20 <== 0.00 1.00 stats table=q20_scan_5 ---- @@ -6157,8 +6011,8 @@ column_names row_count distinct_count null_count {ps_suppkey} 5833 4434 0 ~~~~ column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{ps_partkey} 266667.00 45.72 <== 160127.00 76.03 <== 0.00 1.00 -{ps_suppkey} 266667.00 45.72 <== 9920.00 2.24 <== 0.00 1.00 +{ps_partkey} 37008.00 6.34 <== 22217.00 10.55 <== 0.00 1.00 +{ps_suppkey} 37008.00 6.34 <== 9741.00 2.20 <== 0.00 1.00 stats table=q20_project_7 ---- @@ -6370,7 +6224,7 @@ limit ├── sort │ ├── save-table-name: q21_sort_2 │ ├── columns: s_name:2(char!null) count_rows:69(int) - │ ├── stats: [rows=9628.02122, distinct(2)=9628.02122, null(2)=0, distinct(69)=9628.02122, null(69)=0] + │ ├── stats: [rows=8329.18391, distinct(2)=8329.18391, null(2)=0, distinct(69)=8329.18391, null(69)=0] │ ├── key: (2) │ ├── fd: (2)-->(69) │ ├── ordering: -69,+2 @@ -6378,30 +6232,30 @@ limit │ ├── save-table-name: q21_group_by_3 │ ├── columns: s_name:2(char!null) count_rows:69(int) │ ├── grouping columns: s_name:2(char!null) - │ ├── stats: [rows=9628.02122, distinct(2)=9628.02122, null(2)=0, distinct(69)=9628.02122, null(69)=0] + │ ├── stats: [rows=8329.18391, distinct(2)=8329.18391, null(2)=0, distinct(69)=8329.18391, null(69)=0] │ ├── key: (2) │ ├── fd: (2)-->(69) │ ├── inner-join (lookup orders) │ │ ├── save-table-name: q21_lookup_join_4 │ │ ├── columns: s_suppkey:1(int!null) s_name:2(char!null) s_nationkey:4(int!null) l1.l_orderkey:8(int!null) l1.l_suppkey:10(int!null) l1.l_commitdate:19(date!null) l1.l_receiptdate:20(date!null) o_orderkey:24(int!null) o_orderstatus:26(char!null) n_nationkey:33(int!null) n_name:34(char!null) │ │ ├── key columns: [8] = [24] - │ │ ├── stats: [rows=33144.2984, distinct(1)=9920, null(1)=0, distinct(2)=9628.02122, null(2)=0, distinct(4)=1, null(4)=0, distinct(8)=32069.6931, null(8)=0, distinct(10)=9920, null(10)=0, distinct(19)=2465.99641, null(19)=0, distinct(20)=2553.9941, null(20)=0, distinct(24)=32069.6931, null(24)=0, distinct(26)=1, null(26)=0, distinct(33)=1, null(33)=0, distinct(34)=1, null(34)=0] + │ │ ├── stats: [rows=17924.776, distinct(1)=9920, null(1)=0, distinct(2)=8329.18391, null(2)=0, distinct(4)=1, null(4)=0, distinct(8)=17568.2329, null(8)=0, distinct(10)=9920, null(10)=0, distinct(19)=2464.28129, null(19)=0, distinct(20)=2551.71335, null(20)=0, distinct(24)=17568.2329, null(24)=0, distinct(26)=1, null(26)=0, distinct(33)=1, null(33)=0, distinct(34)=1, null(34)=0] │ │ ├── fd: ()-->(26,34), (1)-->(2,4), (8)==(24), (24)==(8), (1)==(10), (10)==(1), (4)==(33), (33)==(4) │ │ ├── inner-join (hash) │ │ │ ├── save-table-name: q21_inner_join_5 │ │ │ ├── columns: s_suppkey:1(int!null) s_name:2(char!null) s_nationkey:4(int!null) l1.l_orderkey:8(int!null) l1.l_suppkey:10(int!null) l1.l_commitdate:19(date!null) l1.l_receiptdate:20(date!null) n_nationkey:33(int!null) n_name:34(char!null) - │ │ │ ├── stats: [rows=80661.4919, distinct(1)=9920, null(1)=0, distinct(2)=9986.88851, null(2)=0, distinct(4)=1, null(4)=0, distinct(8)=78046.2829, null(8)=0, distinct(10)=9920, null(10)=0, distinct(19)=2466, null(19)=0, distinct(20)=2554, null(20)=0, distinct(33)=1, null(33)=0, distinct(34)=1, null(34)=0] + │ │ │ ├── stats: [rows=17924.776, distinct(1)=9920, null(1)=0, distinct(2)=8329.18391, null(2)=0, distinct(4)=1, null(4)=0, distinct(8)=17568.2329, null(8)=0, distinct(10)=9920, null(10)=0, distinct(19)=2464.28129, null(19)=0, distinct(20)=2551.71335, null(20)=0, distinct(33)=1, null(33)=0, distinct(34)=1, null(34)=0] │ │ │ ├── fd: ()-->(34), (1)-->(2,4), (1)==(10), (10)==(1), (4)==(33), (33)==(4) │ │ │ ├── semi-join (hash) │ │ │ │ ├── save-table-name: q21_semi_join_6 │ │ │ │ ├── columns: l1.l_orderkey:8(int!null) l1.l_suppkey:10(int!null) l1.l_commitdate:19(date!null) l1.l_receiptdate:20(date!null) - │ │ │ │ ├── stats: [rows=2000405, distinct(8)=1216823.04, null(8)=0, distinct(10)=9920, null(10)=0, distinct(19)=2466, null(19)=0, distinct(20)=2554, null(20)=0] + │ │ │ │ ├── stats: [rows=444534.444, distinct(8)=444534.444, null(8)=0, distinct(10)=9920, null(10)=0, distinct(19)=2466, null(19)=0, distinct(20)=2554, null(20)=0] │ │ │ │ ├── anti-join (merge) │ │ │ │ │ ├── save-table-name: q21_merge_join_7 │ │ │ │ │ ├── columns: l1.l_orderkey:8(int!null) l1.l_suppkey:10(int!null) l1.l_commitdate:19(date!null) l1.l_receiptdate:20(date!null) │ │ │ │ │ ├── left ordering: +8 │ │ │ │ │ ├── right ordering: +53 - │ │ │ │ │ ├── stats: [rows=2000405, distinct(8)=1216823.04, null(8)=0, distinct(10)=9920, null(10)=0, distinct(19)=2466, null(19)=0, distinct(20)=2554, null(20)=0] + │ │ │ │ │ ├── stats: [rows=1333603.33, distinct(8)=666801.667, null(8)=0, distinct(10)=9920, null(10)=0, distinct(19)=2466, null(19)=0, distinct(20)=2554, null(20)=0] │ │ │ │ │ ├── select │ │ │ │ │ │ ├── save-table-name: q21_select_8 │ │ │ │ │ │ ├── columns: l1.l_orderkey:8(int!null) l1.l_suppkey:10(int!null) l1.l_commitdate:19(date!null) l1.l_receiptdate:20(date!null) @@ -6512,8 +6366,8 @@ column_names row_count distinct_count null_count {s_name} 100 100 0 ~~~~ column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{count_rows} 9628.00 96.28 <== 9628.00 1203.50 <== 0.00 1.00 -{s_name} 9628.00 96.28 <== 9628.00 96.28 <== 0.00 1.00 +{count_rows} 8329.00 83.29 <== 8329.00 1041.12 <== 0.00 1.00 +{s_name} 8329.00 83.29 <== 8329.00 83.29 <== 0.00 1.00 stats table=q21_group_by_3 ---- @@ -6522,8 +6376,8 @@ column_names row_count distinct_count null_count {s_name} 411 411 0 ~~~~ column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{count_rows} 9628.00 23.43 <== 9628.00 566.35 <== 0.00 1.00 -{s_name} 9628.00 23.43 <== 9628.00 23.43 <== 0.00 1.00 +{count_rows} 8329.00 20.27 <== 8329.00 489.94 <== 0.00 1.00 +{s_name} 8329.00 20.27 <== 8329.00 20.27 <== 0.00 1.00 stats table=q21_lookup_join_4 ---- @@ -6541,17 +6395,17 @@ column_names row_count distinct_count null_count {s_suppkey} 4141 411 0 ~~~~ column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{l_commitdate} 33144.00 8.00 <== 2466.00 2.08 <== 0.00 1.00 -{l_orderkey} 33144.00 8.00 <== 32070.00 7.77 <== 0.00 1.00 -{l_receiptdate} 33144.00 8.00 <== 2554.00 2.18 <== 0.00 1.00 -{l_suppkey} 33144.00 8.00 <== 9920.00 24.14 <== 0.00 1.00 -{n_name} 33144.00 8.00 <== 1.00 1.00 0.00 1.00 -{n_nationkey} 33144.00 8.00 <== 1.00 1.00 0.00 1.00 -{o_orderkey} 33144.00 8.00 <== 32070.00 7.77 <== 0.00 1.00 -{o_orderstatus} 33144.00 8.00 <== 1.00 1.00 0.00 1.00 -{s_name} 33144.00 8.00 <== 9628.00 23.43 <== 0.00 1.00 -{s_nationkey} 33144.00 8.00 <== 1.00 1.00 0.00 1.00 -{s_suppkey} 33144.00 8.00 <== 9920.00 24.14 <== 0.00 1.00 +{l_commitdate} 17925.00 4.33 <== 2464.00 2.07 <== 0.00 1.00 +{l_orderkey} 17925.00 4.33 <== 17568.00 4.26 <== 0.00 1.00 +{l_receiptdate} 17925.00 4.33 <== 2552.00 2.17 <== 0.00 1.00 +{l_suppkey} 17925.00 4.33 <== 9920.00 24.14 <== 0.00 1.00 +{n_name} 17925.00 4.33 <== 1.00 1.00 0.00 1.00 +{n_nationkey} 17925.00 4.33 <== 1.00 1.00 0.00 1.00 +{o_orderkey} 17925.00 4.33 <== 17568.00 4.26 <== 0.00 1.00 +{o_orderstatus} 17925.00 4.33 <== 1.00 1.00 0.00 1.00 +{s_name} 17925.00 4.33 <== 8329.00 20.27 <== 0.00 1.00 +{s_nationkey} 17925.00 4.33 <== 1.00 1.00 0.00 1.00 +{s_suppkey} 17925.00 4.33 <== 9920.00 24.14 <== 0.00 1.00 stats table=q21_inner_join_5 ---- @@ -6567,15 +6421,15 @@ column_names row_count distinct_count null_count {s_suppkey} 8357 411 0 ~~~~ column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{l_commitdate} 80661.00 9.65 <== 2466.00 1.05 0.00 1.00 -{l_orderkey} 80661.00 9.65 <== 78046.00 9.35 <== 0.00 1.00 -{l_receiptdate} 80661.00 9.65 <== 2554.00 1.07 0.00 1.00 -{l_suppkey} 80661.00 9.65 <== 9920.00 24.14 <== 0.00 1.00 -{n_name} 80661.00 9.65 <== 1.00 1.00 0.00 1.00 -{n_nationkey} 80661.00 9.65 <== 1.00 1.00 0.00 1.00 -{s_name} 80661.00 9.65 <== 9987.00 24.30 <== 0.00 1.00 -{s_nationkey} 80661.00 9.65 <== 1.00 1.00 0.00 1.00 -{s_suppkey} 80661.00 9.65 <== 9920.00 24.14 <== 0.00 1.00 +{l_commitdate} 17925.00 2.14 <== 2464.00 1.05 0.00 1.00 +{l_orderkey} 17925.00 2.14 <== 17568.00 2.11 <== 0.00 1.00 +{l_receiptdate} 17925.00 2.14 <== 2552.00 1.07 0.00 1.00 +{l_suppkey} 17925.00 2.14 <== 9920.00 24.14 <== 0.00 1.00 +{n_name} 17925.00 2.14 <== 1.00 1.00 0.00 1.00 +{n_nationkey} 17925.00 2.14 <== 1.00 1.00 0.00 1.00 +{s_name} 17925.00 2.14 <== 8329.00 20.27 <== 0.00 1.00 +{s_nationkey} 17925.00 2.14 <== 1.00 1.00 0.00 1.00 +{s_suppkey} 17925.00 2.14 <== 9920.00 24.14 <== 0.00 1.00 stats table=q21_semi_join_6 ---- @@ -6586,10 +6440,10 @@ column_names row_count distinct_count null_count {l_suppkey} 202092 9920 0 ~~~~ column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{l_commitdate} 2000405.00 9.90 <== 2466.00 1.00 0.00 1.00 -{l_orderkey} 2000405.00 9.90 <== 1216823.00 6.01 <== 0.00 1.00 -{l_receiptdate} 2000405.00 9.90 <== 2554.00 1.02 0.00 1.00 -{l_suppkey} 2000405.00 9.90 <== 9920.00 1.00 0.00 1.00 +{l_commitdate} 444534.00 2.20 <== 2466.00 1.00 0.00 1.00 +{l_orderkey} 444534.00 2.20 <== 444534.00 2.20 <== 0.00 1.00 +{l_receiptdate} 444534.00 2.20 <== 2554.00 1.02 0.00 1.00 +{l_suppkey} 444534.00 2.20 <== 9920.00 1.00 0.00 1.00 stats table=q21_merge_join_7 ---- @@ -6600,10 +6454,10 @@ column_names row_count distinct_count null_count {l_suppkey} 337680 9920 0 ~~~~ column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{l_commitdate} 2000405.00 5.92 <== 2466.00 1.00 0.00 1.00 -{l_orderkey} 2000405.00 5.92 <== 1216823.00 3.60 <== 0.00 1.00 -{l_receiptdate} 2000405.00 5.92 <== 2554.00 1.02 0.00 1.00 -{l_suppkey} 2000405.00 5.92 <== 9920.00 1.00 0.00 1.00 +{l_commitdate} 1333603.00 3.95 <== 2466.00 1.00 0.00 1.00 +{l_orderkey} 1333603.00 3.95 <== 666802.00 1.97 <== 0.00 1.00 +{l_receiptdate} 1333603.00 3.95 <== 2554.00 1.02 0.00 1.00 +{l_suppkey} 1333603.00 3.95 <== 9920.00 1.00 0.00 1.00 stats table=q21_select_8 ---- @@ -6770,170 +6624,102 @@ GROUP BY ORDER BY cntrycode; ---- -group-by - ├── save-table-name: q22_group_by_1 +sort + ├── save-table-name: q22_sort_1 ├── columns: cntrycode:27(string) numcust:28(int) totacctbal:29(float) - ├── grouping columns: cntrycode:27(string) - ├── stats: [rows=16666.6667, distinct(27)=16666.6667, null(27)=0, distinct(28)=16666.6667, null(28)=0, distinct(29)=16666.6667, null(29)=0] + ├── stats: [rows=1e-10, distinct(27)=1e-10, null(27)=0, distinct(28)=1e-10, null(28)=0, distinct(29)=1e-10, null(29)=0] ├── key: (27) ├── fd: (27)-->(28,29) ├── ordering: +27 - ├── sort - │ ├── save-table-name: q22_sort_2 - │ ├── columns: c_acctbal:6(float!null) cntrycode:27(string) - │ ├── stats: [rows=16666.6667, distinct(6)=16666.6667, null(6)=0, distinct(27)=16666.6667, null(27)=0] - │ ├── ordering: +27 - │ └── project - │ ├── save-table-name: q22_project_3 - │ ├── columns: cntrycode:27(string) c_acctbal:6(float!null) - │ ├── stats: [rows=16666.6667, distinct(6)=16666.6667, null(6)=0, distinct(27)=16666.6667, null(27)=0] - │ ├── anti-join (lookup orders@o_ck) - │ │ ├── save-table-name: q22_lookup_join_4 - │ │ ├── columns: c_custkey:1(int!null) c_phone:5(char!null) c_acctbal:6(float!null) - │ │ ├── key columns: [1] = [19] - │ │ ├── stats: [rows=16666.6667, distinct(1)=16658.9936, null(1)=0, distinct(5)=16666.6667, null(5)=0, distinct(6)=16666.6667, null(6)=0] - │ │ ├── key: (1) - │ │ ├── fd: (1)-->(5,6) - │ │ ├── select - │ │ │ ├── save-table-name: q22_select_5 - │ │ │ ├── columns: c_custkey:1(int!null) c_phone:5(char!null) c_acctbal:6(float!null) - │ │ │ ├── stats: [rows=16666.6667, distinct(1)=16658.9936, null(1)=0, distinct(5)=16666.6667, null(5)=0, distinct(6)=16666.6667, null(6)=0] - │ │ │ ├── key: (1) - │ │ │ ├── fd: (1)-->(5,6) - │ │ │ ├── scan customer - │ │ │ │ ├── save-table-name: q22_scan_6 - │ │ │ │ ├── columns: c_custkey:1(int!null) c_phone:5(char!null) c_acctbal:6(float!null) - │ │ │ │ ├── stats: [rows=150000, distinct(1)=148813, null(1)=0, distinct(5)=150000, null(5)=0, distinct(6)=140628, null(6)=0] - │ │ │ │ │ histogram(1)= 0 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 - │ │ │ │ │ <--- 2 ----- 776 ----- 1422 ----- 2189 ----- 2973 ----- 3583 ----- 4390 ----- 5154 ----- 5962 ----- 6965 ----- 7596 ----- 8303 ----- 9167 ----- 9833 ----- 10695 ----- 11397 ----- 11979 ----- 12651 ----- 13397 ----- 14144 ----- 14951 ----- 15698 ----- 16460 ----- 17203 ----- 17846 ----- 18462 ----- 19390 ----- 20189 ----- 20852 ----- 21642 ----- 22379 ----- 23009 ----- 23856 ----- 24734 ----- 25473 ----- 26231 ----- 26978 ----- 27654 ----- 28276 ----- 29054 ----- 29727 ----- 30527 ----- 31177 ----- 32126 ----- 32984 ----- 33684 ----- 34316 ----- 35070 ----- 35703 ----- 36397 ----- 37156 ----- 37709 ----- 38488 ----- 39131 ----- 39740 ----- 40736 ----- 41459 ----- 42388 ----- 42999 ----- 43844 ----- 44571 ----- 45428 ----- 46283 ----- 46979 ----- 47712 ----- 48708 ----- 49487 ----- 50275 ----- 51131 ----- 51836 ----- 52652 ----- 53389 ----- 54179 ----- 54861 ----- 55609 ----- 56492 ----- 57284 ----- 57917 ----- 58793 ----- 59665 ----- 60285 ----- 60840 ----- 61523 ----- 62354 ----- 63178 ----- 63933 ----- 64642 ----- 65282 ----- 65864 ----- 66755 ----- 67407 ----- 68099 ----- 68875 ----- 69638 ----- 70304 ----- 71016 ----- 71830 ----- 72742 ----- 73590 ----- 74434 ----- 75274 ----- 75861 ----- 76547 ----- 77252 ----- 77978 ----- 78650 ----- 79313 ----- 79925 ----- 80677 ----- 81497 ----- 82205 ----- 82962 ----- 83879 ----- 84815 ----- 85521 ----- 86272 ----- 87140 ----- 87759 ----- 88634 ----- 89452 ----- 90192 ----- 90920 ----- 91756 ----- 92690 ----- 93299 ----- 93950 ----- 94812 ----- 95569 ----- 96295 ----- 96904 ----- 97499 ----- 98144 ----- 98764 ----- 99582 ----- 100453 ----- 101098 ----- 101892 ----- 102700 ----- 103419 ----- 104297 ----- 105040 ----- 105864 ----- 106498 ----- 107196 ----- 108022 ----- 108731 ----- 109398 ----- 110145 ----- 110849 ----- 111758 ----- 112501 ----- 113222 ----- 114019 ----- 114904 ----- 115693 ----- 116350 ----- 116955 ----- 117581 ----- 118366 ----- 119159 ----- 119902 ----- 120535 ----- 121321 ----- 121993 ----- 122769 ----- 123504 ----- 124225 ----- 124992 ----- 125632 ----- 126685 ----- 127641 ----- 128303 ----- 129042 ----- 129589 ----- 130548 ----- 131374 ----- 132325 ----- 133042 ----- 133883 ----- 134716 ----- 135520 ----- 136173 ----- 136858 ----- 137584 ----- 138381 ----- 139162 ----- 139923 ----- 140738 ----- 141557 ----- 142287 ----- 143002 ----- 143794 ----- 144420 ----- 145276 ----- 146100 ----- 146977 ----- 147821 ----- 148440 ----- 149247 ----- 149978 - │ │ │ │ ├── key: (1) - │ │ │ │ └── fd: (1)-->(5,6) - │ │ │ └── filters - │ │ │ ├── substring(c_phone, 1, 2) IN ('13', '17', '18', '23', '29', '30', '31') [type=bool, outer=(5)] - │ │ │ └── gt [type=bool, outer=(6), subquery, constraints=(/6: (/NULL - ])] - │ │ │ ├── variable: c_acctbal [type=float] - │ │ │ └── subquery [type=float] - │ │ │ └── scalar-group-by - │ │ │ ├── save-table-name: q22_scalar_group_by_7 - │ │ │ ├── columns: avg:17(float) - │ │ │ ├── cardinality: [1 - 1] - │ │ │ ├── stats: [rows=1, distinct(17)=1, null(17)=0] - │ │ │ ├── key: () - │ │ │ ├── fd: ()-->(17) - │ │ │ ├── select - │ │ │ │ ├── save-table-name: q22_select_8 - │ │ │ │ ├── columns: c_phone:13(char!null) c_acctbal:14(float!null) - │ │ │ │ ├── stats: [rows=16666.6667, distinct(13)=16666.6667, null(13)=0, distinct(14)=16666.6667, null(14)=0] - │ │ │ │ ├── scan customer - │ │ │ │ │ ├── save-table-name: q22_scan_9 - │ │ │ │ │ ├── columns: c_phone:13(char!null) c_acctbal:14(float!null) - │ │ │ │ │ └── stats: [rows=150000, distinct(13)=150000, null(13)=0, distinct(14)=140628, null(14)=0] - │ │ │ │ └── filters - │ │ │ │ ├── c_acctbal > 0.0 [type=bool, outer=(14), constraints=(/14: [/5e-324 - ]; tight)] - │ │ │ │ └── substring(c_phone, 1, 2) IN ('13', '17', '18', '23', '29', '30', '31') [type=bool, outer=(13)] - │ │ │ └── aggregations - │ │ │ └── avg [type=float, outer=(14)] - │ │ │ └── variable: c_acctbal [type=float] - │ │ └── filters (true) - │ └── projections - │ └── substring(c_phone, 1, 2) [type=string, outer=(5)] - └── aggregations - ├── count-rows [type=int] - └── sum [type=float, outer=(6)] - └── variable: c_acctbal [type=float] + └── group-by + ├── save-table-name: q22_group_by_2 + ├── columns: cntrycode:27(string) count_rows:28(int) sum:29(float) + ├── grouping columns: cntrycode:27(string) + ├── stats: [rows=1e-10, distinct(27)=1e-10, null(27)=0, distinct(28)=1e-10, null(28)=0, distinct(29)=1e-10, null(29)=0] + ├── key: (27) + ├── fd: (27)-->(28,29) + ├── project + │ ├── save-table-name: q22_project_3 + │ ├── columns: cntrycode:27(string) c_acctbal:6(float!null) + │ ├── stats: [rows=1e-10, distinct(6)=1e-10, null(6)=0, distinct(27)=1e-10, null(27)=0] + │ ├── anti-join (lookup orders@o_ck) + │ │ ├── save-table-name: q22_lookup_join_4 + │ │ ├── columns: c_custkey:1(int!null) c_phone:5(char!null) c_acctbal:6(float!null) + │ │ ├── key columns: [1] = [19] + │ │ ├── stats: [rows=1e-10, distinct(1)=1e-10, null(1)=0, distinct(5)=1e-10, null(5)=0, distinct(6)=1e-10, null(6)=0] + │ │ ├── key: (1) + │ │ ├── fd: (1)-->(5,6) + │ │ ├── select + │ │ │ ├── save-table-name: q22_select_5 + │ │ │ ├── columns: c_custkey:1(int!null) c_phone:5(char!null) c_acctbal:6(float!null) + │ │ │ ├── stats: [rows=16666.6667, distinct(1)=16658.9936, null(1)=0, distinct(5)=16666.6667, null(5)=0, distinct(6)=16666.6667, null(6)=0] + │ │ │ ├── key: (1) + │ │ │ ├── fd: (1)-->(5,6) + │ │ │ ├── scan customer + │ │ │ │ ├── save-table-name: q22_scan_6 + │ │ │ │ ├── columns: c_custkey:1(int!null) c_phone:5(char!null) c_acctbal:6(float!null) + │ │ │ │ ├── stats: [rows=150000, distinct(1)=148813, null(1)=0, distinct(5)=150000, null(5)=0, distinct(6)=140628, null(6)=0] + │ │ │ │ │ histogram(1)= 0 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 735 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 750 15 + │ │ │ │ │ <--- 2 ----- 776 ----- 1422 ----- 2189 ----- 2973 ----- 3583 ----- 4390 ----- 5154 ----- 5962 ----- 6965 ----- 7596 ----- 8303 ----- 9167 ----- 9833 ----- 10695 ----- 11397 ----- 11979 ----- 12651 ----- 13397 ----- 14144 ----- 14951 ----- 15698 ----- 16460 ----- 17203 ----- 17846 ----- 18462 ----- 19390 ----- 20189 ----- 20852 ----- 21642 ----- 22379 ----- 23009 ----- 23856 ----- 24734 ----- 25473 ----- 26231 ----- 26978 ----- 27654 ----- 28276 ----- 29054 ----- 29727 ----- 30527 ----- 31177 ----- 32126 ----- 32984 ----- 33684 ----- 34316 ----- 35070 ----- 35703 ----- 36397 ----- 37156 ----- 37709 ----- 38488 ----- 39131 ----- 39740 ----- 40736 ----- 41459 ----- 42388 ----- 42999 ----- 43844 ----- 44571 ----- 45428 ----- 46283 ----- 46979 ----- 47712 ----- 48708 ----- 49487 ----- 50275 ----- 51131 ----- 51836 ----- 52652 ----- 53389 ----- 54179 ----- 54861 ----- 55609 ----- 56492 ----- 57284 ----- 57917 ----- 58793 ----- 59665 ----- 60285 ----- 60840 ----- 61523 ----- 62354 ----- 63178 ----- 63933 ----- 64642 ----- 65282 ----- 65864 ----- 66755 ----- 67407 ----- 68099 ----- 68875 ----- 69638 ----- 70304 ----- 71016 ----- 71830 ----- 72742 ----- 73590 ----- 74434 ----- 75274 ----- 75861 ----- 76547 ----- 77252 ----- 77978 ----- 78650 ----- 79313 ----- 79925 ----- 80677 ----- 81497 ----- 82205 ----- 82962 ----- 83879 ----- 84815 ----- 85521 ----- 86272 ----- 87140 ----- 87759 ----- 88634 ----- 89452 ----- 90192 ----- 90920 ----- 91756 ----- 92690 ----- 93299 ----- 93950 ----- 94812 ----- 95569 ----- 96295 ----- 96904 ----- 97499 ----- 98144 ----- 98764 ----- 99582 ----- 100453 ----- 101098 ----- 101892 ----- 102700 ----- 103419 ----- 104297 ----- 105040 ----- 105864 ----- 106498 ----- 107196 ----- 108022 ----- 108731 ----- 109398 ----- 110145 ----- 110849 ----- 111758 ----- 112501 ----- 113222 ----- 114019 ----- 114904 ----- 115693 ----- 116350 ----- 116955 ----- 117581 ----- 118366 ----- 119159 ----- 119902 ----- 120535 ----- 121321 ----- 121993 ----- 122769 ----- 123504 ----- 124225 ----- 124992 ----- 125632 ----- 126685 ----- 127641 ----- 128303 ----- 129042 ----- 129589 ----- 130548 ----- 131374 ----- 132325 ----- 133042 ----- 133883 ----- 134716 ----- 135520 ----- 136173 ----- 136858 ----- 137584 ----- 138381 ----- 139162 ----- 139923 ----- 140738 ----- 141557 ----- 142287 ----- 143002 ----- 143794 ----- 144420 ----- 145276 ----- 146100 ----- 146977 ----- 147821 ----- 148440 ----- 149247 ----- 149978 + │ │ │ │ ├── key: (1) + │ │ │ │ └── fd: (1)-->(5,6) + │ │ │ └── filters + │ │ │ ├── substring(c_phone, 1, 2) IN ('13', '17', '18', '23', '29', '30', '31') [type=bool, outer=(5)] + │ │ │ └── gt [type=bool, outer=(6), subquery, constraints=(/6: (/NULL - ])] + │ │ │ ├── variable: c_acctbal [type=float] + │ │ │ └── subquery [type=float] + │ │ │ └── scalar-group-by + │ │ │ ├── save-table-name: q22_scalar_group_by_7 + │ │ │ ├── columns: avg:17(float) + │ │ │ ├── cardinality: [1 - 1] + │ │ │ ├── stats: [rows=1, distinct(17)=1, null(17)=0] + │ │ │ ├── key: () + │ │ │ ├── fd: ()-->(17) + │ │ │ ├── select + │ │ │ │ ├── save-table-name: q22_select_8 + │ │ │ │ ├── columns: c_phone:13(char!null) c_acctbal:14(float!null) + │ │ │ │ ├── stats: [rows=16666.6667, distinct(13)=16666.6667, null(13)=0, distinct(14)=16666.6667, null(14)=0] + │ │ │ │ ├── scan customer + │ │ │ │ │ ├── save-table-name: q22_scan_9 + │ │ │ │ │ ├── columns: c_phone:13(char!null) c_acctbal:14(float!null) + │ │ │ │ │ └── stats: [rows=150000, distinct(13)=150000, null(13)=0, distinct(14)=140628, null(14)=0] + │ │ │ │ └── filters + │ │ │ │ ├── c_acctbal > 0.0 [type=bool, outer=(14), constraints=(/14: [/5e-324 - ]; tight)] + │ │ │ │ └── substring(c_phone, 1, 2) IN ('13', '17', '18', '23', '29', '30', '31') [type=bool, outer=(13)] + │ │ │ └── aggregations + │ │ │ └── avg [type=float, outer=(14)] + │ │ │ └── variable: c_acctbal [type=float] + │ │ └── filters (true) + │ └── projections + │ └── substring(c_phone, 1, 2) [type=string, outer=(5)] + └── aggregations + ├── count-rows [type=int] + └── sum [type=float, outer=(6)] + └── variable: c_acctbal [type=float] -stats table=q22_group_by_1 +stats table=q22_sort_1 ---- -column_names row_count distinct_count null_count -{cntrycode} 7 7 0 -{numcust} 7 7 0 -{totacctbal} 7 7 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{cntrycode} 16667.00 2381.00 <== 16667.00 2381.00 <== 0.00 1.00 -{numcust} 16667.00 2381.00 <== 16667.00 2381.00 <== 0.00 1.00 -{totacctbal} 16667.00 2381.00 <== 16667.00 2381.00 <== 0.00 1.00 -stats table=q22_sort_2 +stats table=q22_group_by_2 ---- -column_names row_count distinct_count null_count -{c_acctbal} 6384 6304 0 -{cntrycode} 6384 7 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{c_acctbal} 16667.00 2.61 <== 16667.00 2.64 <== 0.00 1.00 -{cntrycode} 16667.00 2.61 <== 16667.00 2381.00 <== 0.00 1.00 stats table=q22_project_3 ---- -column_names row_count distinct_count null_count -{c_acctbal} 6384 6304 0 -{cntrycode} 6384 7 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{c_acctbal} 16667.00 2.61 <== 16667.00 2.64 <== 0.00 1.00 -{cntrycode} 16667.00 2.61 <== 16667.00 2381.00 <== 0.00 1.00 stats table=q22_lookup_join_4 ---- -column_names row_count distinct_count null_count -{c_acctbal} 6384 6304 0 -{c_custkey} 6384 6359 0 -{c_phone} 6384 6428 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{c_acctbal} 16667.00 2.61 <== 16667.00 2.64 <== 0.00 1.00 -{c_custkey} 16667.00 2.61 <== 16659.00 2.62 <== 0.00 1.00 -{c_phone} 16667.00 2.61 <== 16667.00 2.59 <== 0.00 1.00 stats table=q22_select_5 ---- -column_names row_count distinct_count null_count -{c_acctbal} 19000 18527 0 -{c_custkey} 19000 19097 0 -{c_phone} 19000 19095 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{c_acctbal} 16667.00 1.14 16667.00 1.11 0.00 1.00 -{c_custkey} 16667.00 1.14 16659.00 1.15 0.00 1.00 -{c_phone} 16667.00 1.14 16667.00 1.15 0.00 1.00 stats table=q22_scan_6 ---- -column_names row_count distinct_count null_count -{c_acctbal} 150000 140628 0 -{c_custkey} 150000 148813 0 -{c_phone} 150000 150872 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{c_acctbal} 150000.00 1.00 140628.00 1.00 0.00 1.00 -{c_custkey} 150000.00 1.00 148813.00 1.00 0.00 1.00 -{c_phone} 150000.00 1.00 150000.00 1.01 0.00 1.00 stats table=q22_scalar_group_by_7 ---- -column_names row_count distinct_count null_count -{avg} 1 1 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{avg} 1.00 1.00 1.00 1.00 0.00 1.00 stats table=q22_select_8 ---- -column_names row_count distinct_count null_count -{c_acctbal} 38120 37172 0 -{c_phone} 38120 38046 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{c_acctbal} 16667.00 2.29 <== 16667.00 2.23 <== 0.00 1.00 -{c_phone} 16667.00 2.29 <== 16667.00 2.28 <== 0.00 1.00 stats table=q22_scan_9 ---- -column_names row_count distinct_count null_count -{c_acctbal} 150000 140628 0 -{c_phone} 150000 150872 0 -~~~~ -column_names row_count_est row_count_err distinct_count_est distinct_count_err null_count_est null_count_err -{c_acctbal} 150000.00 1.00 140628.00 1.00 0.00 1.00 -{c_phone} 150000.00 1.00 150000.00 1.01 0.00 1.00 diff --git a/pkg/sql/opt/norm/testdata/rules/decorrelate b/pkg/sql/opt/norm/testdata/rules/decorrelate index 76a464e1b0b4..d3ae87b4edea 100644 --- a/pkg/sql/opt/norm/testdata/rules/decorrelate +++ b/pkg/sql/opt/norm/testdata/rules/decorrelate @@ -3222,8 +3222,9 @@ SELECT * FROM a WHERE NOT EXISTS(SELECT * FROM xy WHERE x=k) AND NOT EXISTS(SELECT * FROM xy WHERE x=i) ---- -anti-join (hash) +anti-join (lookup xy) ├── columns: k:1(int!null) i:2(int) f:3(float) s:4(string) j:5(jsonb) + ├── key columns: [1] = [6] ├── key: (1) ├── fd: (1)-->(2-5) ├── anti-join (hash) @@ -3239,11 +3240,7 @@ anti-join (hash) │ │ └── key: (8) │ └── filters │ └── x = i [type=bool, outer=(2,8), constraints=(/2: (/NULL - ]; /8: (/NULL - ]), fd=(2)==(8), (8)==(2)] - ├── scan xy - │ ├── columns: x:6(int!null) - │ └── key: (6) - └── filters - └── x = k [type=bool, outer=(1,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ]), fd=(1)==(6), (6)==(1)] + └── filters (true) # Don't hoist uncorrelated subqueries. opt expect-not=HoistSelectNotExists @@ -3272,8 +3269,9 @@ select opt expect=(HoistSelectExists,HoistSelectNotExists) SELECT * FROM a WHERE EXISTS(SELECT * FROM xy WHERE x=k) AND NOT EXISTS(SELECT * FROM xy WHERE x=i) ---- -semi-join (hash) +semi-join (lookup xy) ├── columns: k:1(int!null) i:2(int) f:3(float) s:4(string) j:5(jsonb) + ├── key columns: [1] = [6] ├── key: (1) ├── fd: (1)-->(2-5) ├── anti-join (hash) @@ -3289,11 +3287,7 @@ semi-join (hash) │ │ └── key: (8) │ └── filters │ └── x = i [type=bool, outer=(2,8), constraints=(/2: (/NULL - ]; /8: (/NULL - ]), fd=(2)==(8), (8)==(2)] - ├── scan xy - │ ├── columns: x:6(int!null) - │ └── key: (6) - └── filters - └── x = k [type=bool, outer=(1,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ]), fd=(1)==(6), (6)==(1)] + └── filters (true) # -------------------------------------------------- # HoistSelectSubquery @@ -5133,6 +5127,10 @@ inner-join (hash) ├── columns: k:1(int!null) i:2(int) f:3(float) s:4(string) j:5(jsonb) x:6(int!null) y:7(int) ├── key: (6) ├── fd: (1)-->(2-5), (6)-->(7), (1)==(6), (6)==(1) + ├── scan xy + │ ├── columns: x:6(int!null) y:7(int) + │ ├── key: (6) + │ └── fd: (6)-->(7) ├── anti-join (hash) │ ├── columns: k:1(int!null) i:2(int) f:3(float) s:4(string) j:5(jsonb) │ ├── key: (1) @@ -5145,10 +5143,6 @@ inner-join (hash) │ │ └── columns: v:9(int) │ └── filters │ └── (i = v) IS NOT false [type=bool, outer=(2,9)] - ├── scan xy - │ ├── columns: x:6(int!null) y:7(int) - │ ├── key: (6) - │ └── fd: (6)-->(7) └── filters └── k = x [type=bool, outer=(1,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ]), fd=(1)==(6), (6)==(1)] diff --git a/pkg/sql/opt/norm/testdata/rules/prune_cols b/pkg/sql/opt/norm/testdata/rules/prune_cols index 0737d39ada40..6ff5c862ee63 100644 --- a/pkg/sql/opt/norm/testdata/rules/prune_cols +++ b/pkg/sql/opt/norm/testdata/rules/prune_cols @@ -937,10 +937,9 @@ WHERE ---- project ├── columns: i:2(int) - └── anti-join (merge) + └── anti-join (lookup xy) ├── columns: k:1(int!null) i:2(int) - ├── left ordering: +1 - ├── right ordering: +5 + ├── key columns: [1] = [5] ├── key: (1) ├── fd: (1)-->(2) ├── anti-join (merge) @@ -949,7 +948,6 @@ project │ ├── right ordering: +7 │ ├── key: (1) │ ├── fd: (1)-->(2) - │ ├── ordering: +1 │ ├── scan a │ │ ├── columns: k:1(int!null) i:2(int) │ │ ├── key: (1) @@ -960,10 +958,6 @@ project │ │ ├── key: (7) │ │ └── ordering: +7 │ └── filters (true) - ├── scan xy - │ ├── columns: x:5(int!null) - │ ├── key: (5) - │ └── ordering: +5 └── filters (true) # -------------------------------------------------- diff --git a/pkg/sql/opt/xform/testdata/external/hibernate b/pkg/sql/opt/xform/testdata/external/hibernate index 52c9ab81044a..dd2b284e1365 100644 --- a/pkg/sql/opt/xform/testdata/external/hibernate +++ b/pkg/sql/opt/xform/testdata/external/hibernate @@ -673,9 +673,16 @@ distinct-on ├── inner-join (hash) │ ├── columns: phone0_.id:1(int!null) person_id:4(int!null) calls1_.phone_id:9(int!null) person2_.id:10(int!null) address:11(varchar) createdon:12(timestamp) name:13(varchar) nickname:14(varchar) version:15(int4!null) │ ├── fd: (1)-->(4), (1)==(9), (9)==(1), (10)-->(11-15), (4)==(10), (10)==(4) + │ ├── scan calls1_ + │ │ └── columns: calls1_.phone_id:9(int) │ ├── inner-join (hash) - │ │ ├── columns: phone0_.id:1(int!null) person_id:4(int) calls1_.phone_id:9(int!null) - │ │ ├── fd: (1)-->(4), (1)==(9), (9)==(1) + │ │ ├── columns: phone0_.id:1(int!null) person_id:4(int!null) person2_.id:10(int!null) address:11(varchar) createdon:12(timestamp) name:13(varchar) nickname:14(varchar) version:15(int4!null) + │ │ ├── key: (1) + │ │ ├── fd: (1)-->(4), (10)-->(11-15), (4)==(10), (10)==(4) + │ │ ├── scan person2_ + │ │ │ ├── columns: person2_.id:10(int!null) address:11(varchar) createdon:12(timestamp) name:13(varchar) nickname:14(varchar) version:15(int4!null) + │ │ │ ├── key: (10) + │ │ │ └── fd: (10)-->(11-15) │ │ ├── anti-join (hash) │ │ │ ├── columns: phone0_.id:1(int!null) person_id:4(int) │ │ │ ├── key: (1) @@ -692,16 +699,10 @@ distinct-on │ │ │ │ └── (call3_.duration >= 50) IS NOT false [type=bool, outer=(17)] │ │ │ └── filters │ │ │ └── call3_.phone_id = phone0_.id [type=bool, outer=(1,19), constraints=(/1: (/NULL - ]; /19: (/NULL - ]), fd=(1)==(19), (19)==(1)] - │ │ ├── scan calls1_ - │ │ │ └── columns: calls1_.phone_id:9(int) │ │ └── filters - │ │ └── phone0_.id = calls1_.phone_id [type=bool, outer=(1,9), constraints=(/1: (/NULL - ]; /9: (/NULL - ]), fd=(1)==(9), (9)==(1)] - │ ├── scan person2_ - │ │ ├── columns: person2_.id:10(int!null) address:11(varchar) createdon:12(timestamp) name:13(varchar) nickname:14(varchar) version:15(int4!null) - │ │ ├── key: (10) - │ │ └── fd: (10)-->(11-15) + │ │ └── person_id = person2_.id [type=bool, outer=(4,10), constraints=(/4: (/NULL - ]; /10: (/NULL - ]), fd=(4)==(10), (10)==(4)] │ └── filters - │ └── person_id = person2_.id [type=bool, outer=(4,10), constraints=(/4: (/NULL - ]; /10: (/NULL - ]), fd=(4)==(10), (10)==(4)] + │ └── phone0_.id = calls1_.phone_id [type=bool, outer=(1,9), constraints=(/1: (/NULL - ]; /9: (/NULL - ]), fd=(1)==(9), (9)==(1)] └── aggregations ├── const-agg [type=varchar, outer=(11)] │ └── variable: address [type=varchar] @@ -1588,8 +1589,9 @@ where company0_.id=employees1_.Company_id and employees1_.employees_id=employee2_.id)) ---- -left-join (hash) +left-join (lookup location) ├── columns: id1_0_0_:1(int!null) id1_8_1_:3(int) location2_0_0_:2(int) address2_8_1_:4(varchar) zip3_8_1_:5(int4) + ├── key columns: [2] = [3] ├── key: (1,3) ├── fd: (1)-->(2), (3)-->(4,5) ├── anti-join (hash) @@ -1632,12 +1634,7 @@ left-join (hash) │ │ └── employees_id = id [type=bool, outer=(7,12), constraints=(/7: (/NULL - ]; /12: (/NULL - ]), fd=(7)==(12), (12)==(7)] │ └── filters │ └── company0_.id = company_id [type=bool, outer=(1,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ]), fd=(1)==(6), (6)==(1)] - ├── scan location3_ - │ ├── columns: location3_.id:3(int!null) address:4(varchar) zip:5(int4!null) - │ ├── key: (3) - │ └── fd: (3)-->(4,5) - └── filters - └── location_id = location3_.id [type=bool, outer=(2,3), constraints=(/2: (/NULL - ]; /3: (/NULL - ]), fd=(2)==(3), (3)==(2)] + └── filters (true) exec-ddl drop table Company, Company_Employee, Employee, Manager, Location; diff --git a/pkg/sql/opt/xform/testdata/external/tpcc b/pkg/sql/opt/xform/testdata/external/tpcc index 1413cda84c14..3364321dbdf8 100644 --- a/pkg/sql/opt/xform/testdata/external/tpcc +++ b/pkg/sql/opt/xform/testdata/external/tpcc @@ -176,7 +176,7 @@ insert "order" ├── cardinality: [0 - 0] ├── side-effects, mutations ├── stats: [rows=0] - ├── cost: 6.15 + ├── cost: 4.05 ├── values │ ├── columns: column1:9(int!null) column2:10(int!null) column3:11(int!null) column4:12(int!null) column5:13(timestamp!null) column6:14(int!null) column7:15(int!null) column16:16(int) │ ├── cardinality: [1 - 1] @@ -196,12 +196,12 @@ insert "order" │ └── null [type=int] └── f-k-checks └── f-k-checks-item: order(o_w_id,o_d_id,o_c_id) -> customer(c_w_id,c_d_id,c_id) - └── anti-join (lookup customer@customer_idx) + └── anti-join (lookup customer) ├── columns: column3:38(int!null) column2:39(int!null) column4:40(int!null) - ├── key columns: [38 39] = [19 18] + ├── key columns: [38 39 40] = [19 18 17] ├── cardinality: [0 - 1] - ├── stats: [rows=1] - ├── cost: 6.12 + ├── stats: [rows=1e-10, distinct(38)=1e-10, null(38)=0, distinct(39)=1e-10, null(39)=0, distinct(40)=1e-10, null(40)=0] + ├── cost: 4.02 ├── key: () ├── fd: ()-->(9-16), (11)-->(38), (10)-->(39), (12)-->(40) ├── with-scan &1 @@ -215,10 +215,7 @@ insert "order" │ ├── cost: 0.01 │ ├── key: () │ └── fd: ()-->(9-16), (11)-->(38), (10)-->(39), (12)-->(40) - └── filters - └── eq [type=bool, outer=(17,40), constraints=(/17: (/NULL - ]; /40: (/NULL - ]), fd=(17)==(40), (40)==(17)] - ├── variable: column4 [type=int] - └── variable: c_id [type=int] + └── filters (true) opt format=hide-qual INSERT INTO new_order (no_o_id, no_d_id, no_w_id) VALUES (2000, 100, 10) @@ -233,7 +230,7 @@ insert new_order ├── cardinality: [0 - 0] ├── side-effects, mutations ├── stats: [rows=0] - ├── cost: 6.14 + ├── cost: 4.05 ├── values │ ├── columns: column1:4(int!null) column2:5(int!null) column3:6(int!null) │ ├── cardinality: [1 - 1] @@ -248,12 +245,12 @@ insert new_order │ └── const: 10 [type=int] └── f-k-checks └── f-k-checks-item: new_order(no_w_id,no_d_id,no_o_id) -> order(o_w_id,o_d_id,o_id) - └── anti-join (lookup order@order_idx) + └── anti-join (lookup order) ├── columns: column3:15(int!null) column2:16(int!null) column1:17(int!null) - ├── key columns: [15 16] = [9 8] + ├── key columns: [15 16 17] = [9 8 7] ├── cardinality: [0 - 1] - ├── stats: [rows=1] - ├── cost: 6.11 + ├── stats: [rows=1e-10, distinct(15)=1e-10, null(15)=0, distinct(16)=1e-10, null(16)=0, distinct(17)=1e-10, null(17)=0] + ├── cost: 4.02 ├── key: () ├── fd: ()-->(4-6), (6)-->(15), (5)-->(16), (4)-->(17) ├── with-scan &1 @@ -267,10 +264,7 @@ insert new_order │ ├── cost: 0.01 │ ├── key: () │ └── fd: ()-->(4-6), (6)-->(15), (5)-->(16), (4)-->(17) - └── filters - └── eq [type=bool, outer=(7,17), constraints=(/7: (/NULL - ]; /17: (/NULL - ]), fd=(7)==(17), (17)==(7)] - ├── variable: column1 [type=int] - └── variable: o_id [type=int] + └── filters (true) opt format=hide-qual UPDATE @@ -703,7 +697,7 @@ insert order_line ├── cardinality: [0 - 0] ├── side-effects, mutations ├── stats: [rows=0] - ├── cost: 73.04 + ├── cost: 48.31 ├── project │ ├── columns: ol_amount:21(decimal) column20:20(timestamp) column1:11(int!null) column2:12(int!null) column3:13(int!null) column4:14(int!null) column5:15(int!null) column6:16(int!null) column7:17(int!null) column9:19(string!null) │ ├── cardinality: [6 - 6] @@ -784,12 +778,12 @@ insert order_line │ └── null [type=timestamp] └── f-k-checks ├── f-k-checks-item: order_line(ol_w_id,ol_d_id,ol_o_id) -> order(o_w_id,o_d_id,o_id) - │ └── anti-join (lookup order@order_idx) + │ └── anti-join (lookup order) │ ├── columns: column3:30(int!null) column2:31(int!null) column1:32(int!null) - │ ├── key columns: [30 31] = [24 23] + │ ├── key columns: [30 31 32] = [24 23 22] │ ├── cardinality: [0 - 6] - │ ├── stats: [rows=6] - │ ├── cost: 36.51 + │ ├── stats: [rows=1e-10, distinct(30)=1e-10, null(30)=0, distinct(31)=1e-10, null(31)=0, distinct(32)=1e-10, null(32)=0] + │ ├── cost: 24.02 │ ├── fd: ()-->(20), (13)-->(30), (12)-->(31), (11)-->(32) │ ├── with-scan &1 │ │ ├── columns: column3:30(int!null) column2:31(int!null) column1:32(int!null) @@ -801,17 +795,14 @@ insert order_line │ │ ├── stats: [rows=6] │ │ ├── cost: 0.01 │ │ └── fd: ()-->(20), (13)-->(30), (12)-->(31), (11)-->(32) - │ └── filters - │ └── eq [type=bool, outer=(22,32), constraints=(/22: (/NULL - ]; /32: (/NULL - ]), fd=(22)==(32), (32)==(22)] - │ ├── variable: column1 [type=int] - │ └── variable: o_id [type=int] + │ └── filters (true) └── f-k-checks-item: order_line(ol_supply_w_id,ol_i_id) -> stock(s_w_id,s_i_id) └── anti-join (lookup stock@stock_item_fk_idx) ├── columns: column6:50(int!null) column5:51(int!null) ├── key columns: [51 50] = [33 34] ├── cardinality: [0 - 6] - ├── stats: [rows=6] - ├── cost: 36.26 + ├── stats: [rows=1e-10, distinct(50)=1e-10, null(50)=0, distinct(51)=1e-10, null(51)=0] + ├── cost: 24.02 ├── fd: ()-->(20), (16)-->(50), (15)-->(51) ├── with-scan &1 │ ├── columns: column6:50(int!null) column5:51(int!null) @@ -1110,7 +1101,7 @@ insert history ├── cardinality: [0 - 0] ├── side-effects, mutations ├── stats: [rows=0] - ├── cost: 12.3 + ├── cost: 8.07 ├── values │ ├── columns: column1:10(int!null) column2:11(int!null) column3:12(int!null) column4:13(int!null) column5:14(int!null) column7:16(timestamp!null) column8:17(string!null) column18:18(uuid) h_amount:19(decimal) │ ├── cardinality: [1 - 1] @@ -1134,12 +1125,12 @@ insert history │ └── const: 2 [type=int] └── f-k-checks ├── f-k-checks-item: history(h_c_w_id,h_c_d_id,h_c_id) -> customer(c_w_id,c_d_id,c_id) - │ └── anti-join (lookup customer@customer_idx) + │ └── anti-join (lookup customer) │ ├── columns: column3:41(int!null) column2:42(int!null) column1:43(int!null) - │ ├── key columns: [41 42] = [22 21] + │ ├── key columns: [41 42 43] = [22 21 20] │ ├── cardinality: [0 - 1] - │ ├── stats: [rows=1] - │ ├── cost: 6.12 + │ ├── stats: [rows=1e-10, distinct(41)=1e-10, null(41)=0, distinct(42)=1e-10, null(42)=0, distinct(43)=1e-10, null(43)=0] + │ ├── cost: 4.02 │ ├── key: () │ ├── fd: ()-->(10-14,16-19), (12)-->(41), (11)-->(42), (10)-->(43) │ ├── with-scan &1 @@ -1153,17 +1144,14 @@ insert history │ │ ├── cost: 0.01 │ │ ├── key: () │ │ └── fd: ()-->(10-14,16-19), (12)-->(41), (11)-->(42), (10)-->(43) - │ └── filters - │ └── eq [type=bool, outer=(20,43), constraints=(/20: (/NULL - ]; /43: (/NULL - ]), fd=(20)==(43), (43)==(20)] - │ ├── variable: column1 [type=int] - │ └── variable: c_id [type=int] + │ └── filters (true) └── f-k-checks-item: history(h_w_id,h_d_id) -> district(d_w_id,d_id) └── anti-join (lookup district) ├── columns: column5:55(int!null) column4:56(int!null) ├── key columns: [55 56] = [45 44] ├── cardinality: [0 - 1] - ├── stats: [rows=1] - ├── cost: 6.15 + ├── stats: [rows=1e-10, distinct(55)=1e-10, null(55)=0, distinct(56)=1e-10, null(56)=0] + ├── cost: 4.02 ├── key: () ├── fd: ()-->(10-14,16-19), (14)-->(55), (13)-->(56) ├── with-scan &1 diff --git a/pkg/sql/opt/xform/testdata/external/tpcc-later-stats b/pkg/sql/opt/xform/testdata/external/tpcc-later-stats index 8c3e76bb04b2..3efbbfdee13c 100644 --- a/pkg/sql/opt/xform/testdata/external/tpcc-later-stats +++ b/pkg/sql/opt/xform/testdata/external/tpcc-later-stats @@ -179,7 +179,7 @@ insert "order" ├── cardinality: [0 - 0] ├── side-effects, mutations ├── stats: [rows=0] - ├── cost: 6.15 + ├── cost: 4.05 ├── values │ ├── columns: column1:9(int!null) column2:10(int!null) column3:11(int!null) column4:12(int!null) column5:13(timestamp!null) column6:14(int!null) column7:15(int!null) column16:16(int) │ ├── cardinality: [1 - 1] @@ -199,12 +199,12 @@ insert "order" │ └── null [type=int] └── f-k-checks └── f-k-checks-item: order(o_w_id,o_d_id,o_c_id) -> customer(c_w_id,c_d_id,c_id) - └── anti-join (lookup customer@customer_idx) + └── anti-join (lookup customer) ├── columns: column3:38(int!null) column2:39(int!null) column4:40(int!null) - ├── key columns: [38 39] = [19 18] + ├── key columns: [38 39 40] = [19 18 17] ├── cardinality: [0 - 1] - ├── stats: [rows=1] - ├── cost: 6.12 + ├── stats: [rows=1e-10, distinct(38)=1e-10, null(38)=0, distinct(39)=1e-10, null(39)=0, distinct(40)=1e-10, null(40)=0] + ├── cost: 4.02 ├── key: () ├── fd: ()-->(9-16), (11)-->(38), (10)-->(39), (12)-->(40) ├── with-scan &1 @@ -218,10 +218,7 @@ insert "order" │ ├── cost: 0.01 │ ├── key: () │ └── fd: ()-->(9-16), (11)-->(38), (10)-->(39), (12)-->(40) - └── filters - └── eq [type=bool, outer=(17,40), constraints=(/17: (/NULL - ]; /40: (/NULL - ]), fd=(17)==(40), (40)==(17)] - ├── variable: column4 [type=int] - └── variable: c_id [type=int] + └── filters (true) opt format=hide-qual INSERT INTO new_order (no_o_id, no_d_id, no_w_id) VALUES (2000, 100, 10) @@ -236,7 +233,7 @@ insert new_order ├── cardinality: [0 - 0] ├── side-effects, mutations ├── stats: [rows=0] - ├── cost: 6.14 + ├── cost: 4.05 ├── values │ ├── columns: column1:4(int!null) column2:5(int!null) column3:6(int!null) │ ├── cardinality: [1 - 1] @@ -251,12 +248,12 @@ insert new_order │ └── const: 10 [type=int] └── f-k-checks └── f-k-checks-item: new_order(no_w_id,no_d_id,no_o_id) -> order(o_w_id,o_d_id,o_id) - └── anti-join (lookup order@order_idx) + └── anti-join (lookup order) ├── columns: column3:15(int!null) column2:16(int!null) column1:17(int!null) - ├── key columns: [15 16] = [9 8] + ├── key columns: [15 16 17] = [9 8 7] ├── cardinality: [0 - 1] - ├── stats: [rows=1] - ├── cost: 6.11 + ├── stats: [rows=1e-10, distinct(15)=1e-10, null(15)=0, distinct(16)=1e-10, null(16)=0, distinct(17)=1e-10, null(17)=0] + ├── cost: 4.02 ├── key: () ├── fd: ()-->(4-6), (6)-->(15), (5)-->(16), (4)-->(17) ├── with-scan &1 @@ -270,10 +267,7 @@ insert new_order │ ├── cost: 0.01 │ ├── key: () │ └── fd: ()-->(4-6), (6)-->(15), (5)-->(16), (4)-->(17) - └── filters - └── eq [type=bool, outer=(7,17), constraints=(/7: (/NULL - ]; /17: (/NULL - ]), fd=(7)==(17), (17)==(7)] - ├── variable: column1 [type=int] - └── variable: o_id [type=int] + └── filters (true) opt format=hide-qual UPDATE @@ -706,7 +700,7 @@ insert order_line ├── cardinality: [0 - 0] ├── side-effects, mutations ├── stats: [rows=0] - ├── cost: 73.04 + ├── cost: 48.31 ├── project │ ├── columns: ol_amount:21(decimal) column20:20(timestamp) column1:11(int!null) column2:12(int!null) column3:13(int!null) column4:14(int!null) column5:15(int!null) column6:16(int!null) column7:17(int!null) column9:19(string!null) │ ├── cardinality: [6 - 6] @@ -787,12 +781,12 @@ insert order_line │ └── null [type=timestamp] └── f-k-checks ├── f-k-checks-item: order_line(ol_w_id,ol_d_id,ol_o_id) -> order(o_w_id,o_d_id,o_id) - │ └── anti-join (lookup order@order_idx) + │ └── anti-join (lookup order) │ ├── columns: column3:30(int!null) column2:31(int!null) column1:32(int!null) - │ ├── key columns: [30 31] = [24 23] + │ ├── key columns: [30 31 32] = [24 23 22] │ ├── cardinality: [0 - 6] - │ ├── stats: [rows=6] - │ ├── cost: 36.51 + │ ├── stats: [rows=1e-10, distinct(30)=1e-10, null(30)=0, distinct(31)=1e-10, null(31)=0, distinct(32)=1e-10, null(32)=0] + │ ├── cost: 24.02 │ ├── fd: ()-->(20), (13)-->(30), (12)-->(31), (11)-->(32) │ ├── with-scan &1 │ │ ├── columns: column3:30(int!null) column2:31(int!null) column1:32(int!null) @@ -804,17 +798,14 @@ insert order_line │ │ ├── stats: [rows=6] │ │ ├── cost: 0.01 │ │ └── fd: ()-->(20), (13)-->(30), (12)-->(31), (11)-->(32) - │ └── filters - │ └── eq [type=bool, outer=(22,32), constraints=(/22: (/NULL - ]; /32: (/NULL - ]), fd=(22)==(32), (32)==(22)] - │ ├── variable: column1 [type=int] - │ └── variable: o_id [type=int] + │ └── filters (true) └── f-k-checks-item: order_line(ol_supply_w_id,ol_i_id) -> stock(s_w_id,s_i_id) └── anti-join (lookup stock@stock_item_fk_idx) ├── columns: column6:50(int!null) column5:51(int!null) ├── key columns: [51 50] = [33 34] ├── cardinality: [0 - 6] - ├── stats: [rows=6] - ├── cost: 36.26 + ├── stats: [rows=1e-10, distinct(50)=1e-10, null(50)=0, distinct(51)=1e-10, null(51)=0] + ├── cost: 24.02 ├── fd: ()-->(20), (16)-->(50), (15)-->(51) ├── with-scan &1 │ ├── columns: column6:50(int!null) column5:51(int!null) @@ -1113,7 +1104,7 @@ insert history ├── cardinality: [0 - 0] ├── side-effects, mutations ├── stats: [rows=0] - ├── cost: 12.3 + ├── cost: 8.07 ├── values │ ├── columns: column1:10(int!null) column2:11(int!null) column3:12(int!null) column4:13(int!null) column5:14(int!null) column7:16(timestamp!null) column8:17(string!null) column18:18(uuid) h_amount:19(decimal) │ ├── cardinality: [1 - 1] @@ -1137,12 +1128,12 @@ insert history │ └── const: 2 [type=int] └── f-k-checks ├── f-k-checks-item: history(h_c_w_id,h_c_d_id,h_c_id) -> customer(c_w_id,c_d_id,c_id) - │ └── anti-join (lookup customer@customer_idx) + │ └── anti-join (lookup customer) │ ├── columns: column3:41(int!null) column2:42(int!null) column1:43(int!null) - │ ├── key columns: [41 42] = [22 21] + │ ├── key columns: [41 42 43] = [22 21 20] │ ├── cardinality: [0 - 1] - │ ├── stats: [rows=1] - │ ├── cost: 6.12 + │ ├── stats: [rows=1e-10, distinct(41)=1e-10, null(41)=0, distinct(42)=1e-10, null(42)=0, distinct(43)=1e-10, null(43)=0] + │ ├── cost: 4.02 │ ├── key: () │ ├── fd: ()-->(10-14,16-19), (12)-->(41), (11)-->(42), (10)-->(43) │ ├── with-scan &1 @@ -1156,17 +1147,14 @@ insert history │ │ ├── cost: 0.01 │ │ ├── key: () │ │ └── fd: ()-->(10-14,16-19), (12)-->(41), (11)-->(42), (10)-->(43) - │ └── filters - │ └── eq [type=bool, outer=(20,43), constraints=(/20: (/NULL - ]; /43: (/NULL - ]), fd=(20)==(43), (43)==(20)] - │ ├── variable: column1 [type=int] - │ └── variable: c_id [type=int] + │ └── filters (true) └── f-k-checks-item: history(h_w_id,h_d_id) -> district(d_w_id,d_id) └── anti-join (lookup district) ├── columns: column5:55(int!null) column4:56(int!null) ├── key columns: [55 56] = [45 44] ├── cardinality: [0 - 1] - ├── stats: [rows=1] - ├── cost: 6.15 + ├── stats: [rows=1e-10, distinct(55)=1e-10, null(55)=0, distinct(56)=1e-10, null(56)=0] + ├── cost: 4.02 ├── key: () ├── fd: ()-->(10-14,16-19), (14)-->(55), (13)-->(56) ├── with-scan &1 diff --git a/pkg/sql/opt/xform/testdata/external/tpcc-no-stats b/pkg/sql/opt/xform/testdata/external/tpcc-no-stats index 0497ceb00fcd..b1484af8467b 100644 --- a/pkg/sql/opt/xform/testdata/external/tpcc-no-stats +++ b/pkg/sql/opt/xform/testdata/external/tpcc-no-stats @@ -173,7 +173,7 @@ insert "order" ├── cardinality: [0 - 0] ├── side-effects, mutations ├── stats: [rows=0] - ├── cost: 6.15 + ├── cost: 4.05 ├── values │ ├── columns: column1:9(int!null) column2:10(int!null) column3:11(int!null) column4:12(int!null) column5:13(timestamp!null) column6:14(int!null) column7:15(int!null) column16:16(int) │ ├── cardinality: [1 - 1] @@ -193,12 +193,12 @@ insert "order" │ └── null [type=int] └── f-k-checks └── f-k-checks-item: order(o_w_id,o_d_id,o_c_id) -> customer(c_w_id,c_d_id,c_id) - └── anti-join (lookup customer@customer_idx) + └── anti-join (lookup customer) ├── columns: column3:38(int!null) column2:39(int!null) column4:40(int!null) - ├── key columns: [38 39] = [19 18] + ├── key columns: [38 39 40] = [19 18 17] ├── cardinality: [0 - 1] - ├── stats: [rows=1] - ├── cost: 6.12 + ├── stats: [rows=1e-10, distinct(38)=1e-10, null(38)=0, distinct(39)=1e-10, null(39)=0, distinct(40)=1e-10, null(40)=0] + ├── cost: 4.02 ├── key: () ├── fd: ()-->(9-16), (11)-->(38), (10)-->(39), (12)-->(40) ├── with-scan &1 @@ -212,10 +212,7 @@ insert "order" │ ├── cost: 0.01 │ ├── key: () │ └── fd: ()-->(9-16), (11)-->(38), (10)-->(39), (12)-->(40) - └── filters - └── eq [type=bool, outer=(17,40), constraints=(/17: (/NULL - ]; /40: (/NULL - ]), fd=(17)==(40), (40)==(17)] - ├── variable: column4 [type=int] - └── variable: c_id [type=int] + └── filters (true) opt format=hide-qual INSERT INTO new_order (no_o_id, no_d_id, no_w_id) VALUES (2000, 100, 10) @@ -230,7 +227,7 @@ insert new_order ├── cardinality: [0 - 0] ├── side-effects, mutations ├── stats: [rows=0] - ├── cost: 6.14 + ├── cost: 4.05 ├── values │ ├── columns: column1:4(int!null) column2:5(int!null) column3:6(int!null) │ ├── cardinality: [1 - 1] @@ -245,12 +242,12 @@ insert new_order │ └── const: 10 [type=int] └── f-k-checks └── f-k-checks-item: new_order(no_w_id,no_d_id,no_o_id) -> order(o_w_id,o_d_id,o_id) - └── anti-join (lookup order@order_idx) + └── anti-join (lookup order) ├── columns: column3:15(int!null) column2:16(int!null) column1:17(int!null) - ├── key columns: [15 16] = [9 8] + ├── key columns: [15 16 17] = [9 8 7] ├── cardinality: [0 - 1] - ├── stats: [rows=1] - ├── cost: 6.11 + ├── stats: [rows=1e-10, distinct(15)=1e-10, null(15)=0, distinct(16)=1e-10, null(16)=0, distinct(17)=1e-10, null(17)=0] + ├── cost: 4.02 ├── key: () ├── fd: ()-->(4-6), (6)-->(15), (5)-->(16), (4)-->(17) ├── with-scan &1 @@ -264,10 +261,7 @@ insert new_order │ ├── cost: 0.01 │ ├── key: () │ └── fd: ()-->(4-6), (6)-->(15), (5)-->(16), (4)-->(17) - └── filters - └── eq [type=bool, outer=(7,17), constraints=(/7: (/NULL - ]; /17: (/NULL - ]), fd=(7)==(17), (17)==(7)] - ├── variable: column1 [type=int] - └── variable: o_id [type=int] + └── filters (true) opt format=hide-qual UPDATE @@ -700,7 +694,7 @@ insert order_line ├── cardinality: [0 - 0] ├── side-effects, mutations ├── stats: [rows=0] - ├── cost: 73.04 + ├── cost: 48.31 ├── project │ ├── columns: ol_amount:21(decimal) column20:20(timestamp) column1:11(int!null) column2:12(int!null) column3:13(int!null) column4:14(int!null) column5:15(int!null) column6:16(int!null) column7:17(int!null) column9:19(string!null) │ ├── cardinality: [6 - 6] @@ -781,12 +775,12 @@ insert order_line │ └── null [type=timestamp] └── f-k-checks ├── f-k-checks-item: order_line(ol_w_id,ol_d_id,ol_o_id) -> order(o_w_id,o_d_id,o_id) - │ └── anti-join (lookup order@order_idx) + │ └── anti-join (lookup order) │ ├── columns: column3:30(int!null) column2:31(int!null) column1:32(int!null) - │ ├── key columns: [30 31] = [24 23] + │ ├── key columns: [30 31 32] = [24 23 22] │ ├── cardinality: [0 - 6] - │ ├── stats: [rows=6] - │ ├── cost: 36.51 + │ ├── stats: [rows=1e-10, distinct(30)=1e-10, null(30)=0, distinct(31)=1e-10, null(31)=0, distinct(32)=1e-10, null(32)=0] + │ ├── cost: 24.02 │ ├── fd: ()-->(20), (13)-->(30), (12)-->(31), (11)-->(32) │ ├── with-scan &1 │ │ ├── columns: column3:30(int!null) column2:31(int!null) column1:32(int!null) @@ -798,17 +792,14 @@ insert order_line │ │ ├── stats: [rows=6] │ │ ├── cost: 0.01 │ │ └── fd: ()-->(20), (13)-->(30), (12)-->(31), (11)-->(32) - │ └── filters - │ └── eq [type=bool, outer=(22,32), constraints=(/22: (/NULL - ]; /32: (/NULL - ]), fd=(22)==(32), (32)==(22)] - │ ├── variable: column1 [type=int] - │ └── variable: o_id [type=int] + │ └── filters (true) └── f-k-checks-item: order_line(ol_supply_w_id,ol_i_id) -> stock(s_w_id,s_i_id) └── anti-join (lookup stock@stock_item_fk_idx) ├── columns: column6:50(int!null) column5:51(int!null) ├── key columns: [51 50] = [33 34] ├── cardinality: [0 - 6] - ├── stats: [rows=6] - ├── cost: 36.26 + ├── stats: [rows=1e-10, distinct(50)=1e-10, null(50)=0, distinct(51)=1e-10, null(51)=0] + ├── cost: 24.02 ├── fd: ()-->(20), (16)-->(50), (15)-->(51) ├── with-scan &1 │ ├── columns: column6:50(int!null) column5:51(int!null) @@ -1107,7 +1098,7 @@ insert history ├── cardinality: [0 - 0] ├── side-effects, mutations ├── stats: [rows=0] - ├── cost: 12.3 + ├── cost: 8.07 ├── values │ ├── columns: column1:10(int!null) column2:11(int!null) column3:12(int!null) column4:13(int!null) column5:14(int!null) column7:16(timestamp!null) column8:17(string!null) column18:18(uuid) h_amount:19(decimal) │ ├── cardinality: [1 - 1] @@ -1131,12 +1122,12 @@ insert history │ └── const: 2 [type=int] └── f-k-checks ├── f-k-checks-item: history(h_c_w_id,h_c_d_id,h_c_id) -> customer(c_w_id,c_d_id,c_id) - │ └── anti-join (lookup customer@customer_idx) + │ └── anti-join (lookup customer) │ ├── columns: column3:41(int!null) column2:42(int!null) column1:43(int!null) - │ ├── key columns: [41 42] = [22 21] + │ ├── key columns: [41 42 43] = [22 21 20] │ ├── cardinality: [0 - 1] - │ ├── stats: [rows=1] - │ ├── cost: 6.12 + │ ├── stats: [rows=1e-10, distinct(41)=1e-10, null(41)=0, distinct(42)=1e-10, null(42)=0, distinct(43)=1e-10, null(43)=0] + │ ├── cost: 4.02 │ ├── key: () │ ├── fd: ()-->(10-14,16-19), (12)-->(41), (11)-->(42), (10)-->(43) │ ├── with-scan &1 @@ -1150,17 +1141,14 @@ insert history │ │ ├── cost: 0.01 │ │ ├── key: () │ │ └── fd: ()-->(10-14,16-19), (12)-->(41), (11)-->(42), (10)-->(43) - │ └── filters - │ └── eq [type=bool, outer=(20,43), constraints=(/20: (/NULL - ]; /43: (/NULL - ]), fd=(20)==(43), (43)==(20)] - │ ├── variable: column1 [type=int] - │ └── variable: c_id [type=int] + │ └── filters (true) └── f-k-checks-item: history(h_w_id,h_d_id) -> district(d_w_id,d_id) └── anti-join (lookup district) ├── columns: column5:55(int!null) column4:56(int!null) ├── key columns: [55 56] = [45 44] ├── cardinality: [0 - 1] - ├── stats: [rows=1] - ├── cost: 6.15 + ├── stats: [rows=1e-10, distinct(55)=1e-10, null(55)=0, distinct(56)=1e-10, null(56)=0] + ├── cost: 4.02 ├── key: () ├── fd: ()-->(10-14,16-19), (14)-->(55), (13)-->(56) ├── with-scan &1 diff --git a/pkg/sql/opt/xform/testdata/external/tpch b/pkg/sql/opt/xform/testdata/external/tpch index a4e70eed8457..5b924baef171 100644 --- a/pkg/sql/opt/xform/testdata/external/tpch +++ b/pkg/sql/opt/xform/testdata/external/tpch @@ -1901,12 +1901,10 @@ limit │ ├── inner-join (hash) │ │ ├── columns: c_custkey:1(int!null) c_name:2(varchar!null) o_orderkey:9(int!null) o_custkey:10(int!null) o_totalprice:12(float!null) o_orderdate:13(date!null) l_orderkey:18(int!null) l_quantity:22(float!null) │ │ ├── fd: (1)-->(2), (9)-->(10,12,13), (9)==(18), (18)==(9), (1)==(10), (10)==(1) - │ │ ├── scan lineitem - │ │ │ └── columns: l_orderkey:18(int!null) l_quantity:22(float!null) - │ │ ├── inner-join (hash) - │ │ │ ├── columns: c_custkey:1(int!null) c_name:2(varchar!null) o_orderkey:9(int!null) o_custkey:10(int!null) o_totalprice:12(float!null) o_orderdate:13(date!null) - │ │ │ ├── key: (9) - │ │ │ ├── fd: (9)-->(10,12,13), (1)-->(2), (1)==(10), (10)==(1) + │ │ ├── inner-join (lookup lineitem) + │ │ │ ├── columns: o_orderkey:9(int!null) o_custkey:10(int!null) o_totalprice:12(float!null) o_orderdate:13(date!null) l_orderkey:18(int!null) l_quantity:22(float!null) + │ │ │ ├── key columns: [9] = [18] + │ │ │ ├── fd: (9)-->(10,12,13), (9)==(18), (18)==(9) │ │ │ ├── semi-join (merge) │ │ │ │ ├── columns: o_orderkey:9(int!null) o_custkey:10(int!null) o_totalprice:12(float!null) o_orderdate:13(date!null) │ │ │ │ ├── left ordering: +9 @@ -1938,14 +1936,13 @@ limit │ │ │ │ │ └── filters │ │ │ │ │ └── sum > 300.0 [type=bool, outer=(50), constraints=(/50: [/300.00000000000006 - ]; tight)] │ │ │ │ └── filters (true) - │ │ │ ├── scan customer - │ │ │ │ ├── columns: c_custkey:1(int!null) c_name:2(varchar!null) - │ │ │ │ ├── key: (1) - │ │ │ │ └── fd: (1)-->(2) - │ │ │ └── filters - │ │ │ └── c_custkey = o_custkey [type=bool, outer=(1,10), constraints=(/1: (/NULL - ]; /10: (/NULL - ]), fd=(1)==(10), (10)==(1)] + │ │ │ └── filters (true) + │ │ ├── scan customer + │ │ │ ├── columns: c_custkey:1(int!null) c_name:2(varchar!null) + │ │ │ ├── key: (1) + │ │ │ └── fd: (1)-->(2) │ │ └── filters - │ │ └── o_orderkey = l_orderkey [type=bool, outer=(9,18), constraints=(/9: (/NULL - ]; /18: (/NULL - ]), fd=(9)==(18), (18)==(9)] + │ │ └── c_custkey = o_custkey [type=bool, outer=(1,10), constraints=(/1: (/NULL - ]; /10: (/NULL - ]), fd=(1)==(10), (10)==(1)] │ └── aggregations │ ├── sum [type=float, outer=(22)] │ │ └── variable: l_quantity [type=float] @@ -2370,54 +2367,55 @@ GROUP BY ORDER BY cntrycode; ---- -group-by +sort ├── columns: cntrycode:27(string) numcust:28(int) totacctbal:29(float) - ├── grouping columns: cntrycode:27(string) ├── key: (27) ├── fd: (27)-->(28,29) ├── ordering: +27 - ├── sort - │ ├── columns: c_acctbal:6(float!null) cntrycode:27(string) - │ ├── ordering: +27 - │ └── project - │ ├── columns: cntrycode:27(string) c_acctbal:6(float!null) - │ ├── anti-join (lookup orders@o_ck) - │ │ ├── columns: c_custkey:1(int!null) c_phone:5(char!null) c_acctbal:6(float!null) - │ │ ├── key columns: [1] = [19] - │ │ ├── key: (1) - │ │ ├── fd: (1)-->(5,6) - │ │ ├── select - │ │ │ ├── columns: c_custkey:1(int!null) c_phone:5(char!null) c_acctbal:6(float!null) - │ │ │ ├── key: (1) - │ │ │ ├── fd: (1)-->(5,6) - │ │ │ ├── scan customer - │ │ │ │ ├── columns: c_custkey:1(int!null) c_phone:5(char!null) c_acctbal:6(float!null) - │ │ │ │ ├── key: (1) - │ │ │ │ └── fd: (1)-->(5,6) - │ │ │ └── filters - │ │ │ ├── substring(c_phone, 1, 2) IN ('13', '17', '18', '23', '29', '30', '31') [type=bool, outer=(5)] - │ │ │ └── gt [type=bool, outer=(6), subquery, constraints=(/6: (/NULL - ])] - │ │ │ ├── variable: c_acctbal [type=float] - │ │ │ └── subquery [type=float] - │ │ │ └── scalar-group-by - │ │ │ ├── columns: avg:17(float) - │ │ │ ├── cardinality: [1 - 1] - │ │ │ ├── key: () - │ │ │ ├── fd: ()-->(17) - │ │ │ ├── select - │ │ │ │ ├── columns: c_phone:13(char!null) c_acctbal:14(float!null) - │ │ │ │ ├── scan customer - │ │ │ │ │ └── columns: c_phone:13(char!null) c_acctbal:14(float!null) - │ │ │ │ └── filters - │ │ │ │ ├── c_acctbal > 0.0 [type=bool, outer=(14), constraints=(/14: [/5e-324 - ]; tight)] - │ │ │ │ └── substring(c_phone, 1, 2) IN ('13', '17', '18', '23', '29', '30', '31') [type=bool, outer=(13)] - │ │ │ └── aggregations - │ │ │ └── avg [type=float, outer=(14)] - │ │ │ └── variable: c_acctbal [type=float] - │ │ └── filters (true) - │ └── projections - │ └── substring(c_phone, 1, 2) [type=string, outer=(5)] - └── aggregations - ├── count-rows [type=int] - └── sum [type=float, outer=(6)] - └── variable: c_acctbal [type=float] + └── group-by + ├── columns: cntrycode:27(string) count_rows:28(int) sum:29(float) + ├── grouping columns: cntrycode:27(string) + ├── key: (27) + ├── fd: (27)-->(28,29) + ├── project + │ ├── columns: cntrycode:27(string) c_acctbal:6(float!null) + │ ├── anti-join (lookup orders@o_ck) + │ │ ├── columns: c_custkey:1(int!null) c_phone:5(char!null) c_acctbal:6(float!null) + │ │ ├── key columns: [1] = [19] + │ │ ├── key: (1) + │ │ ├── fd: (1)-->(5,6) + │ │ ├── select + │ │ │ ├── columns: c_custkey:1(int!null) c_phone:5(char!null) c_acctbal:6(float!null) + │ │ │ ├── key: (1) + │ │ │ ├── fd: (1)-->(5,6) + │ │ │ ├── scan customer + │ │ │ │ ├── columns: c_custkey:1(int!null) c_phone:5(char!null) c_acctbal:6(float!null) + │ │ │ │ ├── key: (1) + │ │ │ │ └── fd: (1)-->(5,6) + │ │ │ └── filters + │ │ │ ├── substring(c_phone, 1, 2) IN ('13', '17', '18', '23', '29', '30', '31') [type=bool, outer=(5)] + │ │ │ └── gt [type=bool, outer=(6), subquery, constraints=(/6: (/NULL - ])] + │ │ │ ├── variable: c_acctbal [type=float] + │ │ │ └── subquery [type=float] + │ │ │ └── scalar-group-by + │ │ │ ├── columns: avg:17(float) + │ │ │ ├── cardinality: [1 - 1] + │ │ │ ├── key: () + │ │ │ ├── fd: ()-->(17) + │ │ │ ├── select + │ │ │ │ ├── columns: c_phone:13(char!null) c_acctbal:14(float!null) + │ │ │ │ ├── scan customer + │ │ │ │ │ └── columns: c_phone:13(char!null) c_acctbal:14(float!null) + │ │ │ │ └── filters + │ │ │ │ ├── c_acctbal > 0.0 [type=bool, outer=(14), constraints=(/14: [/5e-324 - ]; tight)] + │ │ │ │ └── substring(c_phone, 1, 2) IN ('13', '17', '18', '23', '29', '30', '31') [type=bool, outer=(13)] + │ │ │ └── aggregations + │ │ │ └── avg [type=float, outer=(14)] + │ │ │ └── variable: c_acctbal [type=float] + │ │ └── filters (true) + │ └── projections + │ └── substring(c_phone, 1, 2) [type=string, outer=(5)] + └── aggregations + ├── count-rows [type=int] + └── sum [type=float, outer=(6)] + └── variable: c_acctbal [type=float] diff --git a/pkg/sql/opt/xform/testdata/external/tpch-no-stats b/pkg/sql/opt/xform/testdata/external/tpch-no-stats index bcd13f23ef7a..d84fd8f4623d 100644 --- a/pkg/sql/opt/xform/testdata/external/tpch-no-stats +++ b/pkg/sql/opt/xform/testdata/external/tpch-no-stats @@ -1665,8 +1665,9 @@ sort ├── grouping columns: p_brand:9(char!null) p_type:10(varchar!null) p_size:11(int!null) ├── key: (9-11) ├── fd: (9-11)-->(22) - ├── inner-join (hash) + ├── inner-join (lookup part) │ ├── columns: ps_partkey:1(int!null) ps_suppkey:2(int!null) p_partkey:6(int!null) p_brand:9(char!null) p_type:10(varchar!null) p_size:11(int!null) + │ ├── key columns: [1] = [6] │ ├── key: (2,6) │ ├── fd: (6)-->(9-11), (1)==(6), (6)==(1) │ ├── anti-join (merge) @@ -1691,20 +1692,10 @@ sort │ │ │ └── filters │ │ │ └── s_comment LIKE '%Customer%Complaints%' [type=bool, outer=(21), constraints=(/21: (/NULL - ])] │ │ └── filters (true) - │ ├── select - │ │ ├── columns: p_partkey:6(int!null) p_brand:9(char!null) p_type:10(varchar!null) p_size:11(int!null) - │ │ ├── key: (6) - │ │ ├── fd: (6)-->(9-11) - │ │ ├── scan part - │ │ │ ├── columns: p_partkey:6(int!null) p_brand:9(char!null) p_type:10(varchar!null) p_size:11(int!null) - │ │ │ ├── key: (6) - │ │ │ └── fd: (6)-->(9-11) - │ │ └── filters - │ │ ├── p_brand != 'Brand#45' [type=bool, outer=(9), constraints=(/9: (/NULL - /'Brand#45') [/e'Brand#45\x00' - ]; tight)] - │ │ ├── p_type NOT LIKE 'MEDIUM POLISHED %' [type=bool, outer=(10), constraints=(/10: (/NULL - ])] - │ │ └── p_size IN (3, 9, 14, 19, 23, 36, 45, 49) [type=bool, outer=(11), constraints=(/11: [/3 - /3] [/9 - /9] [/14 - /14] [/19 - /19] [/23 - /23] [/36 - /36] [/45 - /45] [/49 - /49]; tight)] │ └── filters - │ └── p_partkey = ps_partkey [type=bool, outer=(1,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ]), fd=(1)==(6), (6)==(1)] + │ ├── p_brand != 'Brand#45' [type=bool, outer=(9), constraints=(/9: (/NULL - /'Brand#45') [/e'Brand#45\x00' - ]; tight)] + │ ├── p_type NOT LIKE 'MEDIUM POLISHED %' [type=bool, outer=(10), constraints=(/10: (/NULL - ])] + │ └── p_size IN (3, 9, 14, 19, 23, 36, 45, 49) [type=bool, outer=(11), constraints=(/11: [/3 - /3] [/9 - /9] [/14 - /14] [/19 - /19] [/23 - /23] [/36 - /36] [/45 - /45] [/49 - /49]; tight)] └── aggregations └── count [type=int, outer=(2)] └── agg-distinct [type=int] @@ -1876,20 +1867,20 @@ limit │ └── group-by │ ├── columns: c_custkey:1(int) c_name:2(varchar) o_orderkey:9(int!null) o_totalprice:12(float) o_orderdate:13(date) sum:51(float) │ ├── grouping columns: o_orderkey:9(int!null) + │ ├── internal-ordering: +(9|18) │ ├── key: (9) │ ├── fd: (1)-->(2), (9)-->(1,2,12,13,51) - │ ├── inner-join (hash) + │ ├── inner-join (lookup lineitem) │ │ ├── columns: c_custkey:1(int!null) c_name:2(varchar!null) o_orderkey:9(int!null) o_custkey:10(int!null) o_totalprice:12(float!null) o_orderdate:13(date!null) l_orderkey:18(int!null) l_quantity:22(float!null) + │ │ ├── key columns: [9] = [18] │ │ ├── fd: (1)-->(2), (9)-->(10,12,13), (9)==(18), (18)==(9), (1)==(10), (10)==(1) - │ │ ├── scan customer - │ │ │ ├── columns: c_custkey:1(int!null) c_name:2(varchar!null) - │ │ │ ├── key: (1) - │ │ │ └── fd: (1)-->(2) - │ │ ├── inner-join (merge) - │ │ │ ├── columns: o_orderkey:9(int!null) o_custkey:10(int!null) o_totalprice:12(float!null) o_orderdate:13(date!null) l_orderkey:18(int!null) l_quantity:22(float!null) - │ │ │ ├── left ordering: +9 - │ │ │ ├── right ordering: +18 - │ │ │ ├── fd: (9)-->(10,12,13), (9)==(18), (18)==(9) + │ │ ├── ordering: +(9|18) [actual: +9] + │ │ ├── inner-join (lookup customer) + │ │ │ ├── columns: c_custkey:1(int!null) c_name:2(varchar!null) o_orderkey:9(int!null) o_custkey:10(int!null) o_totalprice:12(float!null) o_orderdate:13(date!null) + │ │ │ ├── key columns: [10] = [1] + │ │ │ ├── key: (9) + │ │ │ ├── fd: (9)-->(10,12,13), (1)-->(2), (1)==(10), (10)==(1) + │ │ │ ├── ordering: +9 │ │ │ ├── project │ │ │ │ ├── columns: o_orderkey:9(int!null) o_custkey:10(int!null) o_totalprice:12(float!null) o_orderdate:13(date!null) │ │ │ │ ├── key: (9) @@ -1921,12 +1912,8 @@ limit │ │ │ │ │ └── filters │ │ │ │ │ └── sum > 300.0 [type=bool, outer=(50), constraints=(/50: [/300.00000000000006 - ]; tight)] │ │ │ │ └── filters (true) - │ │ │ ├── scan lineitem - │ │ │ │ ├── columns: l_orderkey:18(int!null) l_quantity:22(float!null) - │ │ │ │ └── ordering: +18 │ │ │ └── filters (true) - │ │ └── filters - │ │ └── c_custkey = o_custkey [type=bool, outer=(1,10), constraints=(/1: (/NULL - ]; /10: (/NULL - ]), fd=(1)==(10), (10)==(1)] + │ │ └── filters (true) │ └── aggregations │ ├── sum [type=float, outer=(22)] │ │ └── variable: l_quantity [type=float] @@ -2233,8 +2220,9 @@ limit │ │ │ ├── columns: s_suppkey:1(int!null) s_name:2(char!null) s_nationkey:4(int!null) l1.l_orderkey:8(int!null) l1.l_suppkey:10(int!null) l1.l_commitdate:19(date!null) l1.l_receiptdate:20(date!null) o_orderkey:24(int!null) o_orderstatus:26(char!null) │ │ │ ├── key columns: [10] = [1] │ │ │ ├── fd: ()-->(26), (8)==(24), (24)==(8), (1)-->(2,4), (1)==(10), (10)==(1) - │ │ │ ├── inner-join (hash) + │ │ │ ├── inner-join (lookup orders) │ │ │ │ ├── columns: l1.l_orderkey:8(int!null) l1.l_suppkey:10(int!null) l1.l_commitdate:19(date!null) l1.l_receiptdate:20(date!null) o_orderkey:24(int!null) o_orderstatus:26(char!null) + │ │ │ │ ├── key columns: [8] = [24] │ │ │ │ ├── fd: ()-->(26), (8)==(24), (24)==(8) │ │ │ │ ├── semi-join (hash) │ │ │ │ │ ├── columns: l1.l_orderkey:8(int!null) l1.l_suppkey:10(int!null) l1.l_commitdate:19(date!null) l1.l_receiptdate:20(date!null) @@ -2265,18 +2253,8 @@ limit │ │ │ │ │ └── filters │ │ │ │ │ ├── l2.l_orderkey = l1.l_orderkey [type=bool, outer=(8,37), constraints=(/8: (/NULL - ]; /37: (/NULL - ]), fd=(8)==(37), (37)==(8)] │ │ │ │ │ └── l2.l_suppkey != l1.l_suppkey [type=bool, outer=(10,39), constraints=(/10: (/NULL - ]; /39: (/NULL - ])] - │ │ │ │ ├── select - │ │ │ │ │ ├── columns: o_orderkey:24(int!null) o_orderstatus:26(char!null) - │ │ │ │ │ ├── key: (24) - │ │ │ │ │ ├── fd: ()-->(26) - │ │ │ │ │ ├── scan orders - │ │ │ │ │ │ ├── columns: o_orderkey:24(int!null) o_orderstatus:26(char!null) - │ │ │ │ │ │ ├── key: (24) - │ │ │ │ │ │ └── fd: (24)-->(26) - │ │ │ │ │ └── filters - │ │ │ │ │ └── o_orderstatus = 'F' [type=bool, outer=(26), constraints=(/26: [/'F' - /'F']; tight), fd=()-->(26)] │ │ │ │ └── filters - │ │ │ │ └── o_orderkey = l1.l_orderkey [type=bool, outer=(8,24), constraints=(/8: (/NULL - ]; /24: (/NULL - ]), fd=(8)==(24), (24)==(8)] + │ │ │ │ └── o_orderstatus = 'F' [type=bool, outer=(26), constraints=(/26: [/'F' - /'F']; tight), fd=()-->(26)] │ │ │ └── filters (true) │ │ └── filters │ │ └── n_name = 'SAUDI ARABIA' [type=bool, outer=(34), constraints=(/34: [/'SAUDI ARABIA' - /'SAUDI ARABIA']; tight), fd=()-->(34)] diff --git a/pkg/sql/opt/xform/testdata/rules/join b/pkg/sql/opt/xform/testdata/rules/join index 80f6bdd78cbf..a2c1c1652f17 100644 --- a/pkg/sql/opt/xform/testdata/rules/join +++ b/pkg/sql/opt/xform/testdata/rules/join @@ -2390,13 +2390,13 @@ SELECT * from abc WHERE EXISTS (SELECT * FROM def WHERE a=d AND c=e) semi-join (lookup def) ├── columns: a:1(int) b:2(int) c:3(int) ├── key columns: [1 3] = [5 6] - ├── stats: [rows=100] + ├── stats: [rows=100, distinct(1)=100, null(1)=0, distinct(3)=10, null(3)=0] ├── cost: 712.03 ├── prune: (2) ├── interesting orderings: (+1,+2) (+2,+3) ├── scan t.public.abc │ ├── columns: t.public.abc.a:1(int) t.public.abc.b:2(int) t.public.abc.c:3(int) - │ ├── stats: [rows=100] + │ ├── stats: [rows=100, distinct(1)=100, null(1)=0, distinct(3)=10, null(3)=1] │ ├── cost: 107.02 │ ├── prune: (1-3) │ └── interesting orderings: (+1,+2) (+2,+3) @@ -2410,7 +2410,7 @@ SELECT * from abc WHERE EXISTS (SELECT * FROM def WHERE a=d AND c=e) ---- project ├── columns: a:1(int) b:2(int) c:3(int) - ├── stats: [rows=100] + ├── stats: [rows=100, distinct(1)=100, null(1)=0, distinct(3)=10, null(3)=0] ├── cost: 508.0605 ├── prune: (2) ├── interesting orderings: (+1,+2) (+2,+3)