diff --git a/pkg/sql/opt/exec/execbuilder/testdata/explain b/pkg/sql/opt/exec/execbuilder/testdata/explain index 4309474052ce..24185b4f1dc2 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/explain +++ b/pkg/sql/opt/exec/execbuilder/testdata/explain @@ -588,14 +588,14 @@ project ├── columns: r:1(int!null) ├── cardinality: [1 - 1] ├── stats: [rows=1] - ├── cost: 0.03 + ├── cost: 0.05 ├── key: () ├── fd: ()-->(1) ├── prune: (1) ├── values │ ├── cardinality: [1 - 1] │ ├── stats: [rows=1] - │ ├── cost: 0.01 + │ ├── cost: 0.02 │ ├── key: () │ └── tuple [type=tuple] └── projections diff --git a/pkg/sql/opt/memo/testdata/logprops/constraints b/pkg/sql/opt/memo/testdata/logprops/constraints index 60caf0012647..137a084ed26f 100644 --- a/pkg/sql/opt/memo/testdata/logprops/constraints +++ b/pkg/sql/opt/memo/testdata/logprops/constraints @@ -700,7 +700,7 @@ scan c@v ├── columns: k:1(int!null) u:2(int!null) v:3(int!null) ├── constraint: /3/2/1: [/1/2 - /1/4] ├── stats: [rows=0.29403, distinct(1)=0.29403, null(1)=0, distinct(2)=0.29403, null(2)=0, distinct(3)=0.29403, null(3)=0] - ├── cost: 0.3116718 + ├── cost: 0.3216718 ├── key: (1) ├── fd: ()-->(3), (1)-->(2) ├── prune: (1) @@ -713,7 +713,7 @@ scan c@v ├── columns: k:1(int!null) u:2(int!null) v:3(int!null) ├── constraint: /3/2/1: [/1/2 - /1/2] [/3/2 - /3/2] [/5/2 - /5/2] ├── stats: [rows=0.29403, distinct(1)=0.29403, null(1)=0, distinct(2)=0.29403, null(2)=0, distinct(3)=0.29403, null(3)=0] - ├── cost: 0.3116718 + ├── cost: 0.3216718 ├── key: (1) ├── fd: ()-->(2), (1)-->(3) ├── prune: (1) @@ -726,7 +726,7 @@ scan c@v ├── columns: k:1(int!null) u:2(int!null) v:3(int!null) ├── constraint: /3/2/1: [/1/2 - /1/2] ├── stats: [rows=0.09801, distinct(1)=0.09801, null(1)=0, distinct(2)=0.09801, null(2)=0, distinct(3)=0.09801, null(3)=0] - ├── cost: 0.1038906 + ├── cost: 0.1138906 ├── key: (1) ├── fd: ()-->(2,3) ├── prune: (1) @@ -739,7 +739,7 @@ scan c@v ├── columns: k:1(int!null) u:2(int!null) v:3(int!null) ├── constraint: /3/2/1: [/1/2 - /1/4] ├── stats: [rows=0.29403, distinct(1)=0.29403, null(1)=0, distinct(2)=0.29403, null(2)=0, distinct(3)=0.29403, null(3)=0] - ├── cost: 0.3116718 + ├── cost: 0.3216718 ├── key: (1) ├── fd: ()-->(3), (1)-->(2) ├── prune: (1) @@ -752,7 +752,7 @@ scan c@v ├── columns: k:1(int!null) u:2(int!null) v:3(int!null) ├── constraint: /3/2/1: [/1/2 - /1/2] [/3/2 - /3/2] [/5/2 - /5/2] ├── stats: [rows=0.29403, distinct(1)=0.29403, null(1)=0, distinct(2)=0.29403, null(2)=0, distinct(3)=0.29403, null(3)=0] - ├── cost: 0.3116718 + ├── cost: 0.3216718 ├── key: (1) ├── fd: ()-->(2), (1)-->(3) ├── prune: (1) @@ -765,7 +765,7 @@ scan c@v ├── columns: k:1(int!null) u:2(int!null) v:3(int!null) ├── constraint: /3/2/1: [/1/2 - /1/2] ├── stats: [rows=0.09801, distinct(1)=0.09801, null(1)=0, distinct(2)=0.09801, null(2)=0, distinct(3)=0.09801, null(3)=0] - ├── cost: 0.1038906 + ├── cost: 0.1138906 ├── key: (1) ├── fd: ()-->(2,3) ├── prune: (1) @@ -905,7 +905,7 @@ SELECT * FROM d WHERE (p, q) IN ((1, 2), (1, 3), (1, 4)) select ├── columns: k:1(int!null) p:2(int!null) q:3(int!null) ├── stats: [rows=0.29403, distinct(1)=0.29403, null(1)=0, distinct(2)=0.29403, null(2)=0, distinct(3)=0.29403, null(3)=0] - ├── cost: 1070 + ├── cost: 1070.02 ├── key: (1) ├── fd: ()-->(2), (1)-->(3) ├── prune: (1) @@ -913,7 +913,7 @@ select ├── scan d │ ├── columns: k:1(int!null) p:2(int) q:3(int) │ ├── stats: [rows=1000, distinct(1)=1000, null(1)=0, distinct(2)=100, null(2)=10, distinct(3)=100, null(3)=10] - │ ├── cost: 1060 + │ ├── cost: 1060.01 │ ├── key: (1) │ ├── fd: (1)-->(2,3) │ ├── prune: (1-3) @@ -940,7 +940,7 @@ SELECT * FROM d WHERE (p, q) IN ((2, 1), (3, 1), (4, 1)) select ├── columns: k:1(int!null) p:2(int!null) q:3(int!null) ├── stats: [rows=0.29403, distinct(1)=0.29403, null(1)=0, distinct(2)=0.29403, null(2)=0, distinct(3)=0.29403, null(3)=0] - ├── cost: 1070 + ├── cost: 1070.02 ├── key: (1) ├── fd: ()-->(3), (1)-->(2) ├── prune: (1) @@ -948,7 +948,7 @@ select ├── scan d │ ├── columns: k:1(int!null) p:2(int) q:3(int) │ ├── stats: [rows=1000, distinct(1)=1000, null(1)=0, distinct(2)=100, null(2)=10, distinct(3)=100, null(3)=10] - │ ├── cost: 1060 + │ ├── cost: 1060.01 │ ├── key: (1) │ ├── fd: (1)-->(2,3) │ ├── prune: (1-3) diff --git a/pkg/sql/opt/memo/testdata/memo b/pkg/sql/opt/memo/testdata/memo index 26b74a497241..1813262f6a00 100644 --- a/pkg/sql/opt/memo/testdata/memo +++ b/pkg/sql/opt/memo/testdata/memo @@ -134,44 +134,44 @@ memo (optimized, ~15KB, required=[presentation: y:2,x:3,c:6] [ordering: +2]) ├── G1: (project G2 G3 y x) │ ├── [presentation: y:2,x:3,c:6] [ordering: +2] │ │ ├── best: (project G2="[ordering: +2]" G3 y x) - │ │ └── cost: 2170.29 + │ │ └── cost: 2170.37 │ └── [] │ ├── best: (project G2 G3 y x) - │ └── cost: 2170.29 + │ └── cost: 2170.37 ├── G2: (limit G4 G5 ordering=+2) │ ├── [ordering: +2] │ │ ├── best: (limit G4="[ordering: +2]" G5 ordering=+2) - │ │ └── cost: 2170.09 + │ │ └── cost: 2170.16 │ └── [] │ ├── best: (limit G4="[ordering: +2]" G5 ordering=+2) - │ └── cost: 2170.09 + │ └── cost: 2170.16 ├── G3: (projections G6) ├── G4: (inner-join G7 G8 G9) (inner-join G8 G7 G9) (lookup-join G7 G10 b,keyCols=[5],outCols=(2,3,5)) (merge-join G8 G7 G10 inner-join,+3,+5) │ ├── [ordering: +2] │ │ ├── best: (sort G4) - │ │ └── cost: 2169.99 + │ │ └── cost: 2170.05 │ └── [] │ ├── best: (inner-join G8 G7 G9) - │ └── cost: 2108.17 + │ └── cost: 2108.22 ├── G5: (const 10) ├── G6: (plus G11 G12) ├── G7: (project G13 G14 y) │ ├── [ordering: +2] │ │ ├── best: (sort G7) - │ │ └── cost: 1118.42 + │ │ └── cost: 1118.46 │ ├── [ordering: +5] │ │ ├── best: (sort G7) - │ │ └── cost: 1118.42 + │ │ └── cost: 1118.46 │ └── [] │ ├── best: (project G13 G14 y) - │ └── cost: 1056.60 + │ └── cost: 1056.63 ├── G8: (scan b,cols=(3)) │ ├── [ordering: +3] │ │ ├── best: (scan b,cols=(3)) - │ │ └── cost: 1030.00 + │ │ └── cost: 1030.01 │ └── [] │ ├── best: (scan b,cols=(3)) - │ └── cost: 1030.00 + │ └── cost: 1030.01 ├── G9: (filters G15) ├── G10: (filters) ├── G11: (variable y) @@ -179,19 +179,19 @@ memo (optimized, ~15KB, required=[presentation: y:2,x:3,c:6] [ordering: +2]) ├── G13: (select G16 G17) │ ├── [ordering: +2] │ │ ├── best: (sort G13) - │ │ └── cost: 1111.82 + │ │ └── cost: 1111.85 │ └── [] │ ├── best: (select G16 G17) - │ └── cost: 1050.00 + │ └── cost: 1050.02 ├── G14: (projections G18) ├── G15: (eq G19 G20) ├── G16: (scan a) │ ├── [ordering: +2] │ │ ├── best: (sort G16) - │ │ └── cost: 1259.32 + │ │ └── cost: 1259.34 │ └── [] │ ├── best: (scan a) - │ └── cost: 1040.00 + │ └── cost: 1040.01 ├── G17: (filters G21) ├── G18: (cast G22 STRING) ├── G19: (variable column5) @@ -209,16 +209,16 @@ memo (optimized, ~3KB, required=[presentation: a:3,b:4,c:5,d:6]) ├── G1: (project G2 G3) │ └── [presentation: a:3,b:4,c:5,d:6] │ ├── best: (project G2 G3) - │ └── cost: 1050.17 + │ └── cost: 1050.20 ├── G2: (select G4 G5) │ └── [] │ ├── best: (select G4 G5) - │ └── cost: 1050.00 + │ └── cost: 1050.02 ├── G3: (projections G6 G7 G8 G9) ├── G4: (scan b) │ └── [] │ ├── best: (scan b) - │ └── cost: 1040.00 + │ └── cost: 1040.01 ├── G5: (filters G10 G11) ├── G6: (const 1) ├── G7: (plus G12 G13) @@ -244,21 +244,21 @@ memo (optimized, ~4KB, required=[presentation: x:1]) ├── G1: (project G2 G3 x) │ └── [presentation: x:1] │ ├── best: (project G2 G3 x) - │ └── cost: 1.05 + │ └── cost: 1.08 ├── G2: (select G4 G5) (select G6 G7) │ └── [] │ ├── best: (select G6 G7) - │ └── cost: 1.05 + │ └── cost: 1.07 ├── G3: (projections) ├── G4: (scan a) │ └── [] │ ├── best: (scan a) - │ └── cost: 1040.00 + │ └── cost: 1040.01 ├── G5: (filters G8 G9) ├── G6: (scan a,constrained) │ └── [] │ ├── best: (scan a,constrained) - │ └── cost: 1.04 + │ └── cost: 1.05 ├── G7: (filters G9) ├── G8: (eq G10 G11) ├── G9: (eq G12 G11) @@ -274,19 +274,19 @@ memo (optimized, ~4KB, required=[presentation: x:7,y:8]) ├── G1: (union G2 G3) │ └── [presentation: x:7,y:8] │ ├── best: (union G2 G3) - │ └── cost: 2149.80 + │ └── cost: 2149.84 ├── G2: (scan a) │ └── [] │ ├── best: (scan a) - │ └── cost: 1040.00 + │ └── cost: 1040.01 ├── G3: (project G4 G5) │ └── [] │ ├── best: (project G4 G5) - │ └── cost: 1070.00 + │ └── cost: 1070.02 ├── G4: (scan a) │ └── [] │ ├── best: (scan a) - │ └── cost: 1040.00 + │ └── cost: 1040.01 ├── G5: (projections G6 G7) ├── G6: (plus G8 G9) ├── G7: (plus G10 G9) @@ -301,11 +301,11 @@ memo (optimized, ~3KB, required=[presentation: array_agg:3]) ├── G1: (scalar-group-by G2 G3 cols=()) │ └── [presentation: array_agg:3] │ ├── best: (scalar-group-by G2 G3 cols=()) - │ └── cost: 1040.01 + │ └── cost: 1040.03 ├── G2: (scan a,cols=(1)) │ └── [] │ ├── best: (scan a,cols=(1)) - │ └── cost: 1030.00 + │ └── cost: 1030.01 ├── G3: (aggregations G4) ├── G4: (array-agg G5) └── G5: (variable x) @@ -317,16 +317,16 @@ memo (optimized, ~3KB, required=[presentation: array_agg:3]) ├── G1: (project G2 G3 array_agg) │ └── [presentation: array_agg:3] │ ├── best: (project G2 G3 array_agg) - │ └── cost: 1072.00 + │ └── cost: 1072.03 ├── G2: (group-by G4 G5 cols=(2)) │ └── [] │ ├── best: (group-by G4 G5 cols=(2)) - │ └── cost: 1071.00 + │ └── cost: 1071.02 ├── G3: (projections) ├── G4: (scan a) │ └── [] │ ├── best: (scan a) - │ └── cost: 1040.00 + │ └── cost: 1040.01 ├── G5: (aggregations G6) ├── G6: (array-agg G7) └── G7: (variable x) @@ -338,14 +338,14 @@ memo (optimized, ~2KB, required=[presentation: array_agg:3]) ├── G1: (scalar-group-by G2 G3 cols=(),ordering=+2) │ └── [presentation: array_agg:3] │ ├── best: (scalar-group-by G2="[ordering: +2]" G3 cols=(),ordering=+2) - │ └── cost: 1269.33 + │ └── cost: 1269.36 ├── G2: (scan a) │ ├── [ordering: +2] │ │ ├── best: (sort G2) - │ │ └── cost: 1259.32 + │ │ └── cost: 1259.34 │ └── [] │ ├── best: (scan a) - │ └── cost: 1040.00 + │ └── cost: 1040.01 ├── G3: (aggregations G4) ├── G4: (array-agg G5) └── G5: (variable x) @@ -357,20 +357,20 @@ memo (optimized, ~4KB, required=[presentation: field:3]) ├── G1: (distinct-on G2 G3 cols=(3)) │ └── [presentation: field:3] │ ├── best: (distinct-on G2 G3 cols=(3)) - │ └── cost: 0.03 + │ └── cost: 0.07 ├── G2: (explain G4 [presentation: k:1]) │ └── [] │ ├── best: (explain G4="[presentation: k:1]" [presentation: k:1]) - │ └── cost: 0.03 + │ └── cost: 0.06 ├── G3: (aggregations) ├── G4: (project G5 G6) │ └── [presentation: k:1] │ ├── best: (project G5 G6) - │ └── cost: 0.03 + │ └── cost: 0.05 ├── G5: (values G7) │ └── [] │ ├── best: (values G7) - │ └── cost: 0.01 + │ └── cost: 0.02 ├── G6: (projections G8) ├── G7: (scalar-list G9) ├── G8: (const 123) @@ -384,9 +384,9 @@ memo (optimized, ~2KB, required=[presentation: tag:4]) ├── G1: (distinct-on G2 G3 cols=(4)) │ └── [presentation: tag:4] │ ├── best: (distinct-on G2 G3 cols=(4)) - │ └── cost: 0.00 + │ └── cost: 0.02 ├── G2: (show-trace-for-session &{TRACE false [1 2 3 4 5 6 7]}) │ └── [] │ ├── best: (show-trace-for-session &{TRACE false [1 2 3 4 5 6 7]}) - │ └── cost: 0.00 + │ └── cost: 0.01 └── G3: (aggregations) diff --git a/pkg/sql/opt/norm/testdata/rules/combo b/pkg/sql/opt/norm/testdata/rules/combo index 7eb712ba5c5a..eb1c76ef3652 100644 --- a/pkg/sql/opt/norm/testdata/rules/combo +++ b/pkg/sql/opt/norm/testdata/rules/combo @@ -39,7 +39,7 @@ SELECT s FROM a INNER JOIN xy ON a.k=xy.x AND i+1=10 ---- ================================================================================ Initial expression - Cost: 8836.67 + Cost: 8836.71 ================================================================================ project ├── columns: s:4(string) @@ -59,7 +59,7 @@ Initial expression └── (k = x) AND ((i + 1) = 10) [type=bool, outer=(1,2,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ])] ================================================================================ NormalizeCmpPlusConst - Cost: 8770.00 + Cost: 8770.04 ================================================================================ project ├── columns: s:4(string) @@ -81,7 +81,7 @@ NormalizeCmpPlusConst + └── (k = x) AND (i = (10 - 1)) [type=bool, outer=(1,2,6), constraints=(/1: (/NULL - ]; /2: (/NULL - ]; /6: (/NULL - ])] ================================================================================ FoldBinary - Cost: 2236.00 + Cost: 2236.04 ================================================================================ project ├── columns: s:4(string) @@ -103,7 +103,7 @@ FoldBinary + └── (k = x) AND (i = 9) [type=bool, outer=(1,2,6), constraints=(/1: (/NULL - ]; /2: [/9 - /9]; /6: (/NULL - ]), fd=()-->(2)] ================================================================================ SimplifyJoinFilters - Cost: 2170.20 + Cost: 2170.24 ================================================================================ project ├── columns: s:4(string) @@ -127,7 +127,7 @@ SimplifyJoinFilters + └── i = 9 [type=bool, outer=(2), constraints=(/2: [/9 - /9]; tight), fd=()-->(2)] ================================================================================ PushFilterIntoJoinLeft - Cost: 2167.82 + Cost: 2167.87 ================================================================================ project ├── columns: s:4(string) @@ -158,7 +158,7 @@ PushFilterIntoJoinLeft + └── k = x [type=bool, outer=(1,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ]), fd=(1)==(6), (6)==(1)] ================================================================================ PruneJoinLeftCols - Cost: 2167.92 + Cost: 2167.98 ================================================================================ project ├── columns: s:4(string) @@ -199,7 +199,7 @@ PruneJoinLeftCols └── k = x [type=bool, outer=(1,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ]), fd=(1)==(6), (6)==(1)] ================================================================================ PruneSelectCols - Cost: 2147.92 + Cost: 2147.98 ================================================================================ project ├── columns: s:4(string) @@ -233,7 +233,7 @@ PruneSelectCols └── k = x [type=bool, outer=(1,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ]), fd=(1)==(6), (6)==(1)] ================================================================================ EliminateProject - Cost: 2147.82 + Cost: 2147.87 ================================================================================ project ├── columns: s:4(string) @@ -270,7 +270,7 @@ EliminateProject └── k = x [type=bool, outer=(1,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ]), fd=(1)==(6), (6)==(1)] ================================================================================ PruneJoinRightCols - Cost: 2137.82 + Cost: 2137.87 ================================================================================ project ├── columns: s:4(string) @@ -309,7 +309,7 @@ GenerateIndexScans (no changes) -------------------------------------------------------------------------------- ================================================================================ CommuteJoin - Cost: 2132.87 + Cost: 2132.92 ================================================================================ project ├── columns: s:4(string) @@ -337,7 +337,7 @@ CommuteJoin └── k = x [type=bool, outer=(1,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ]), fd=(1)==(6), (6)==(1)] ================================================================================ GenerateMergeJoins - Cost: 2130.30 + Cost: 2130.35 ================================================================================ project ├── columns: s:4(string) @@ -373,7 +373,7 @@ GenerateMergeJoins + └── filters (true) ================================================================================ GenerateLookupJoins - Cost: 1139.90 + Cost: 1139.94 ================================================================================ project ├── columns: s:4(string) @@ -414,7 +414,7 @@ GenerateLookupJoinsWithFilter (no changes) -------------------------------------------------------------------------------- ================================================================================ Final best expression - Cost: 1139.90 + Cost: 1139.94 ================================================================================ project ├── columns: s:4(string) @@ -441,7 +441,7 @@ SELECT s, k FROM a WHERE s='foo' AND f>100 ---- ================================================================================ Initial expression - Cost: 1110.03 + Cost: 1110.06 ================================================================================ project ├── columns: s:4(string!null) k:1(int!null) @@ -459,7 +459,7 @@ Initial expression └── (s = 'foo') AND (f > 100.0) [type=bool, outer=(3,4), constraints=(/3: [/100.00000000000001 - ]; /4: [/'foo' - /'foo']; tight), fd=()-->(4)] ================================================================================ SimplifySelectFilters - Cost: 1110.03 + Cost: 1110.06 ================================================================================ project ├── columns: s:4(string!null) k:1(int!null) @@ -479,7 +479,7 @@ SimplifySelectFilters + └── f > 100.0 [type=bool, outer=(3), constraints=(/3: [/100.00000000000001 - ]; tight)] ================================================================================ PruneSelectCols - Cost: 1090.03 + Cost: 1090.06 ================================================================================ project ├── columns: s:4(string!null) k:1(int!null) @@ -502,7 +502,7 @@ PruneSelectCols └── f > 100.0 [type=bool, outer=(3), constraints=(/3: [/100.00000000000001 - ]; tight)] ================================================================================ GenerateIndexScans - Cost: 1080.03 + Cost: 1080.06 ================================================================================ project ├── columns: s:4(string!null) k:1(int!null) @@ -522,7 +522,7 @@ GenerateIndexScans └── f > 100.0 [type=bool, outer=(3), constraints=(/3: [/100.00000000000001 - ]; tight)] ================================================================================ GenerateConstrainedScans - Cost: 3.53 + Cost: 3.55 ================================================================================ project ├── columns: s:4(string!null) k:1(int!null) @@ -544,7 +544,7 @@ GenerateConstrainedScans + └── fd: ()-->(4), (1)-->(3), (3)-->(1) ================================================================================ Final best expression - Cost: 3.53 + Cost: 3.55 ================================================================================ project ├── columns: s:4(string!null) k:1(int!null) @@ -562,7 +562,7 @@ SELECT * FROM a WHERE EXISTS(SELECT * FROM xy WHERE y=i) ---- ================================================================================ Initial expression - Cost: 2160.00 + Cost: 2160.04 ================================================================================ select ├── columns: k:1(int!null) i:2(int) f:3(float) s:4(string) j:5(jsonb) @@ -587,7 +587,7 @@ Initial expression └── y = i [type=bool, outer=(2,7), constraints=(/2: (/NULL - ]; /7: (/NULL - ]), fd=(2)==(7), (7)==(2)] ================================================================================ HoistSelectExists - Cost: 2200.00 + Cost: 2200.05 ================================================================================ select ├── columns: k:1(int!null) i:2(int) f:3(float) s:4(string) j:5(jsonb) @@ -631,7 +631,7 @@ HoistSelectExists + └── filters (true) ================================================================================ TryDecorrelateSelect - Cost: 2190.00 + Cost: 2190.04 ================================================================================ select - ├── columns: k:1(int!null) i:2(int) f:3(float) s:4(string) j:5(jsonb) @@ -667,7 +667,7 @@ TryDecorrelateSelect └── filters (true) ================================================================================ DecorrelateJoin - Cost: 2190.00 + Cost: 2190.04 ================================================================================ select - ├── columns: k:1(int!null) i:2(int!null) f:3(float) s:4(string) j:5(jsonb) @@ -693,7 +693,7 @@ DecorrelateJoin └── filters (true) ================================================================================ EliminateSelect - Cost: 2180.00 + Cost: 2180.03 ================================================================================ -select +semi-join @@ -734,7 +734,7 @@ GenerateMergeJoins (no changes) -------------------------------------------------------------------------------- ================================================================================ Final best expression - Cost: 2180.00 + Cost: 2180.03 ================================================================================ semi-join ├── columns: k:1(int!null) i:2(int) f:3(float) s:4(string) j:5(jsonb) @@ -757,7 +757,7 @@ SELECT 5=ANY(SELECT i FROM a WHERE k=x) AS r FROM xy ---- ================================================================================ Initial expression - Cost: 2170.01 + Cost: 2170.06 ================================================================================ project ├── columns: r:8(bool) @@ -788,7 +788,7 @@ Initial expression └── const: 5 [type=int] ================================================================================ PruneSelectCols - Cost: 2140.01 + Cost: 2140.06 ================================================================================ project ├── columns: r:8(bool) @@ -823,7 +823,7 @@ PruneSelectCols └── const: 5 [type=int] ================================================================================ PruneScanCols - Cost: 2130.01 + Cost: 2130.06 ================================================================================ project ├── columns: r:8(bool) @@ -856,7 +856,7 @@ PruneScanCols └── const: 5 [type=int] ================================================================================ HoistProjectSubquery - Cost: 2152.58 + Cost: 2152.68 ================================================================================ project ├── columns: r:8(bool) @@ -946,7 +946,7 @@ HoistProjectSubquery + └── variable: case [type=bool, outer=(11)] ================================================================================ CommuteVar - Cost: 2152.58 + Cost: 2152.68 ================================================================================ project ├── columns: r:8(bool) @@ -1014,7 +1014,7 @@ CommuteVar └── variable: case [type=bool, outer=(11)] ================================================================================ PushSelectIntoProject - Cost: 2152.57 + Cost: 2152.68 ================================================================================ project ├── columns: r:8(bool) @@ -1094,7 +1094,7 @@ PushSelectIntoProject └── variable: case [type=bool, outer=(11)] ================================================================================ MergeSelects - Cost: 2152.60 + Cost: 2152.70 ================================================================================ project ├── columns: r:8(bool) @@ -1172,7 +1172,7 @@ MergeSelects └── variable: case [type=bool, outer=(11)] ================================================================================ EliminateSelect - Cost: 2152.59 + Cost: 2152.68 ================================================================================ project ├── columns: r:8(bool) @@ -1253,7 +1253,7 @@ EliminateSelect └── variable: case [type=bool, outer=(11)] ================================================================================ MergeProjects - Cost: 2152.58 + Cost: 2152.66 ================================================================================ project ├── columns: r:8(bool) @@ -1323,7 +1323,7 @@ MergeProjects └── variable: case [type=bool, outer=(11)] ================================================================================ FoldNonNullIsNotNull - Cost: 2152.58 + Cost: 2152.66 ================================================================================ project ├── columns: r:8(bool) @@ -1378,7 +1378,7 @@ FoldNonNullIsNotNull └── variable: case [type=bool, outer=(11)] ================================================================================ SimplifyAndTrue - Cost: 2152.58 + Cost: 2152.66 ================================================================================ project ├── columns: r:8(bool) @@ -1433,7 +1433,7 @@ SimplifyAndTrue └── variable: case [type=bool, outer=(11)] ================================================================================ TryDecorrelateProject - Cost: 2182.56 + Cost: 2182.65 ================================================================================ project ├── columns: r:8(bool) @@ -1523,7 +1523,7 @@ TryDecorrelateProject └── variable: case [type=bool, outer=(11)] ================================================================================ TryDecorrelateScalarGroupBy - Cost: 2232.54 + Cost: 2232.64 ================================================================================ project ├── columns: r:8(bool) @@ -1611,7 +1611,7 @@ TryDecorrelateScalarGroupBy └── variable: case [type=bool, outer=(11)] ================================================================================ TryDecorrelateProjectSelect - Cost: 2270.00 + Cost: 2270.10 ================================================================================ project ├── columns: r:8(bool) @@ -1693,7 +1693,7 @@ TryDecorrelateProjectSelect └── variable: case [type=bool, outer=(11)] ================================================================================ DecorrelateJoin - Cost: 2270.00 + Cost: 2270.10 ================================================================================ project ├── columns: r:8(bool) @@ -1749,7 +1749,7 @@ DecorrelateJoin └── variable: case [type=bool, outer=(11)] ================================================================================ PushFilterIntoJoinRight - Cost: 2268.33 + Cost: 2268.44 ================================================================================ project ├── columns: r:8(bool) @@ -1817,7 +1817,7 @@ PushFilterIntoJoinRight └── variable: case [type=bool, outer=(11)] ================================================================================ PushSelectIntoProject - Cost: 2258.33 + Cost: 2258.45 ================================================================================ project ├── columns: r:8(bool) @@ -1885,7 +1885,7 @@ PushSelectIntoProject └── variable: case [type=bool, outer=(11)] ================================================================================ EliminateSelect - Cost: 2255.00 + Cost: 2255.11 ================================================================================ project ├── columns: r:8(bool) @@ -1960,7 +1960,7 @@ EliminateSelect └── variable: case [type=bool, outer=(11)] ================================================================================ PruneJoinRightCols - Cost: 2255.00 + Cost: 2255.11 ================================================================================ project ├── columns: r:8(bool) @@ -2023,7 +2023,7 @@ PruneJoinRightCols └── variable: case [type=bool, outer=(11)] ================================================================================ EliminateGroupByProject - Cost: 2245.00 + Cost: 2245.10 ================================================================================ project ├── columns: r:8(bool) @@ -2107,7 +2107,7 @@ EliminateGroupByProject └── variable: case [type=bool, outer=(11)] ================================================================================ EliminateSelect - Cost: 2235.00 + Cost: 2235.09 ================================================================================ project ├── columns: r:8(bool) @@ -2190,7 +2190,7 @@ EliminateSelect └── variable: case [type=bool, outer=(11)] ================================================================================ EliminateSelect - Cost: 2225.00 + Cost: 2225.08 ================================================================================ project ├── columns: r:8(bool) @@ -2274,7 +2274,7 @@ EliminateSelect └── variable: case [type=bool, outer=(11)] ================================================================================ PruneProjectCols - Cost: 2225.00 + Cost: 2225.08 ================================================================================ project ├── columns: r:8(bool) @@ -2322,7 +2322,7 @@ PruneProjectCols └── variable: case [type=bool, outer=(11)] ================================================================================ InlineProjectInProject - Cost: 2205.00 + Cost: 2205.07 ================================================================================ project ├── columns: r:8(bool) @@ -2409,7 +2409,7 @@ CommuteLeftJoin (no changes) -------------------------------------------------------------------------------- ================================================================================ GenerateMergeJoins - Cost: 2200.00 + Cost: 2200.07 ================================================================================ project ├── columns: r:8(bool) @@ -2466,7 +2466,7 @@ GenerateMergeJoins (no changes) -------------------------------------------------------------------------------- ================================================================================ GenerateStreamingGroupBy - Cost: 2190.00 + Cost: 2190.07 ================================================================================ project ├── columns: r:8(bool) @@ -2514,7 +2514,7 @@ GenerateStreamingGroupBy └── CASE WHEN bool_or THEN true WHEN bool_or IS NULL THEN false END [type=bool, outer=(10)] ================================================================================ Final best expression - Cost: 2190.00 + Cost: 2190.07 ================================================================================ project ├── columns: r:8(bool) diff --git a/pkg/sql/opt/norm/testdata/rules/fold_constants b/pkg/sql/opt/norm/testdata/rules/fold_constants index 17bac8789c74..1f2d079c4b47 100644 --- a/pkg/sql/opt/norm/testdata/rules/fold_constants +++ b/pkg/sql/opt/norm/testdata/rules/fold_constants @@ -368,14 +368,14 @@ project ├── columns: "?column?":1(int) ├── cardinality: [1 - 1] ├── stats: [rows=1] - ├── cost: 0.03 + ├── cost: 0.05 ├── key: () ├── fd: ()-->(1) ├── prune: (1) ├── values │ ├── cardinality: [1 - 1] │ ├── stats: [rows=1] - │ ├── cost: 0.01 + │ ├── cost: 0.02 │ ├── key: () │ └── tuple [type=tuple] └── projections @@ -389,14 +389,14 @@ project ├── columns: "?column?":1(decimal!null) ├── cardinality: [1 - 1] ├── stats: [rows=1] - ├── cost: 0.03 + ├── cost: 0.05 ├── key: () ├── fd: ()-->(1) ├── prune: (1) ├── values │ ├── cardinality: [1 - 1] │ ├── stats: [rows=1] - │ ├── cost: 0.01 + │ ├── cost: 0.02 │ ├── key: () │ └── tuple [type=tuple] └── projections @@ -409,14 +409,14 @@ project ├── columns: "?column?":1(interval!null) ├── cardinality: [1 - 1] ├── stats: [rows=1] - ├── cost: 0.03 + ├── cost: 0.05 ├── key: () ├── fd: ()-->(1) ├── prune: (1) ├── values │ ├── cardinality: [1 - 1] │ ├── stats: [rows=1] - │ ├── cost: 0.01 + │ ├── cost: 0.02 │ ├── key: () │ └── tuple [type=tuple] └── projections diff --git a/pkg/sql/opt/norm/testdata/rules/scalar b/pkg/sql/opt/norm/testdata/rules/scalar index 79eb9c58e88a..c8b068a96763 100644 --- a/pkg/sql/opt/norm/testdata/rules/scalar +++ b/pkg/sql/opt/norm/testdata/rules/scalar @@ -875,7 +875,7 @@ SELECT k FROM e WHERE i IS NOT DISTINCT FROM NULL::FLOAT project ├── columns: k:1(int!null) ├── stats: [rows=10] - ├── cost: 10.5 + ├── cost: 10.52 ├── key: (1) ├── prune: (1) ├── interesting orderings: (+1) @@ -883,7 +883,7 @@ project ├── columns: t.public.e.k:1(int!null) t.public.e.i:2(int) ├── constraint: /2/1: [/NULL - /NULL] ├── stats: [rows=10, distinct(1)=10, null(1)=0, distinct(2)=1, null(2)=10] - ├── cost: 10.4 + ├── cost: 10.41 ├── key: (1) ├── fd: ()-->(2) ├── prune: (1,2) @@ -895,7 +895,7 @@ SELECT k FROM e WHERE i IS DISTINCT FROM NULL::FLOAT project ├── columns: k:1(int!null) ├── stats: [rows=990] - ├── cost: 1039.5 + ├── cost: 1039.52 ├── key: (1) ├── prune: (1) ├── interesting orderings: (+1) @@ -903,7 +903,7 @@ project ├── columns: t.public.e.k:1(int!null) t.public.e.i:2(int!null) ├── constraint: /2/1: (/NULL - ] ├── stats: [rows=990, distinct(1)=990, null(1)=0, distinct(2)=100, null(2)=0] - ├── cost: 1029.6 + ├── cost: 1029.61 ├── key: (1) ├── fd: (1)-->(2) ├── prune: (1,2) diff --git a/pkg/sql/opt/xform/coster.go b/pkg/sql/opt/xform/coster.go index 82eb840f17cc..d4ba469e9ab5 100644 --- a/pkg/sql/opt/xform/coster.go +++ b/pkg/sql/opt/xform/coster.go @@ -149,6 +149,12 @@ func (c *coster) ComputeCost(candidate memo.RelExpr, required *physical.Required // without EXPLAIN, i.e. the lowest cost plan. So do nothing special to get // default behavior. } + + // Add a one-time cost for any operator, meant to reflect the cost of setting + // up execution for the operator. This makes plans with fewer operators + // preferable, all else being equal. + cost += cpuCostFactor + if !cost.Less(memo.MaxCost) { // Optsteps uses MaxCost to suppress nodes in the memo. When a node with // MaxCost is added to the memo, it can lead to an obscure crash with an diff --git a/pkg/sql/opt/xform/testdata/coster/groupby b/pkg/sql/opt/xform/testdata/coster/groupby index 1504009ab33e..710174138c45 100644 --- a/pkg/sql/opt/xform/testdata/coster/groupby +++ b/pkg/sql/opt/xform/testdata/coster/groupby @@ -16,13 +16,13 @@ group-by ├── columns: max:5(int) min:6(int) i:2(int) s:3(string) ├── grouping columns: i:2(int) s:3(string) ├── stats: [rows=1000, distinct(2,3)=1000, null(2,3)=19.9] - ├── cost: 1130 + ├── cost: 1130.02 ├── key: (2,3) ├── fd: (2,3)-->(5,6) ├── scan a │ ├── columns: k:1(int!null) i:2(int) s:3(string) │ ├── stats: [rows=1000, distinct(2,3)=1000, null(2,3)=19.9] - │ ├── cost: 1070 + │ ├── cost: 1070.01 │ ├── key: (1) │ └── fd: (1)-->(2,3) └── aggregations diff --git a/pkg/sql/opt/xform/testdata/coster/join b/pkg/sql/opt/xform/testdata/coster/join index e2009f28bc95..9f1deab6d0ee 100644 --- a/pkg/sql/opt/xform/testdata/coster/join +++ b/pkg/sql/opt/xform/testdata/coster/join @@ -25,27 +25,27 @@ SELECT k, x FROM a INNER JOIN b ON k=x WHERE d=1.0 project ├── columns: k:1(int!null) x:5(int!null) ├── stats: [rows=100] - ├── cost: 2124.675 + ├── cost: 2124.725 ├── fd: (1)==(5), (5)==(1) └── inner-join ├── columns: k:1(int!null) d:4(decimal!null) x:5(int!null) ├── stats: [rows=100, distinct(1)=10, null(1)=0, distinct(4)=1, null(4)=0, distinct(5)=10, null(5)=0] - ├── cost: 2123.675 + ├── cost: 2123.715 ├── fd: ()-->(4), (1)==(5), (5)==(1) ├── scan b │ ├── columns: x:5(int) │ ├── stats: [rows=1000, distinct(5)=100, null(5)=10] - │ └── cost: 1040 + │ └── cost: 1040.01 ├── select │ ├── columns: k:1(int!null) d:4(decimal!null) │ ├── stats: [rows=10, distinct(1)=10, null(1)=0, distinct(4)=1, null(4)=0] - │ ├── cost: 1070 + │ ├── cost: 1070.02 │ ├── key: (1) │ ├── fd: ()-->(4) │ ├── scan a │ │ ├── columns: k:1(int!null) d:4(decimal!null) │ │ ├── stats: [rows=1000, distinct(1)=1000, null(1)=0, distinct(4)=100, null(4)=0] - │ │ ├── cost: 1060 + │ │ ├── cost: 1060.01 │ │ ├── key: (1) │ │ └── fd: (1)-->(4) │ └── filters @@ -84,13 +84,13 @@ SELECT * FROM abc WHERE c = 1 index-join abc ├── columns: a:1(int!null) b:2(int) c:3(int!null) ├── stats: [rows=9.9, distinct(1)=9.9, null(1)=0, distinct(3)=1, null(3)=0] - ├── cost: 50.589 + ├── cost: 50.609 ├── key: (1) ├── fd: ()-->(3), (1)-->(2) └── scan abc@c_idx ├── columns: a:1(int!null) c:3(int!null) ├── constraint: /3/1: [/1 - /1] ├── stats: [rows=9.9, distinct(1)=9.9, null(1)=0, distinct(3)=1, null(3)=0] - ├── cost: 10.296 + ├── cost: 10.306 ├── key: (1) └── fd: ()-->(3) diff --git a/pkg/sql/opt/xform/testdata/coster/project b/pkg/sql/opt/xform/testdata/coster/project index 5e810448840c..fcc4de24c4d7 100644 --- a/pkg/sql/opt/xform/testdata/coster/project +++ b/pkg/sql/opt/xform/testdata/coster/project @@ -15,13 +15,13 @@ SELECT k, i, s || 'foo' FROM a project ├── columns: k:1(int!null) i:2(int) "?column?":5(string) ├── stats: [rows=1000] - ├── cost: 1090 + ├── cost: 1090.02 ├── key: (1) ├── fd: (1)-->(2,5) ├── scan a │ ├── columns: k:1(int!null) i:2(int) s:3(string) │ ├── stats: [rows=1000] - │ ├── cost: 1070 + │ ├── cost: 1070.01 │ ├── key: (1) │ └── fd: (1)-->(2,3) └── projections @@ -33,13 +33,13 @@ SELECT k, k+2, i*d FROM a project ├── columns: k:1(int!null) "?column?":5(int) "?column?":6(decimal) ├── stats: [rows=1000] - ├── cost: 1100 + ├── cost: 1100.02 ├── key: (1) ├── fd: (1)-->(5,6) ├── scan a │ ├── columns: k:1(int!null) i:2(int) d:4(decimal!null) │ ├── stats: [rows=1000] - │ ├── cost: 1070 + │ ├── cost: 1070.01 │ ├── key: (1) │ └── fd: (1)-->(2,4) └── projections diff --git a/pkg/sql/opt/xform/testdata/coster/scan b/pkg/sql/opt/xform/testdata/coster/scan index 137b78528b77..1febae8833cb 100644 --- a/pkg/sql/opt/xform/testdata/coster/scan +++ b/pkg/sql/opt/xform/testdata/coster/scan @@ -15,6 +15,6 @@ SELECT k, s FROM a scan a ├── columns: k:1(int!null) s:3(string) ├── stats: [rows=1000] - ├── cost: 1060 + ├── cost: 1060.01 ├── key: (1) └── fd: (1)-->(3) diff --git a/pkg/sql/opt/xform/testdata/coster/select b/pkg/sql/opt/xform/testdata/coster/select index bca1238caf20..6981cfcd817a 100644 --- a/pkg/sql/opt/xform/testdata/coster/select +++ b/pkg/sql/opt/xform/testdata/coster/select @@ -15,13 +15,13 @@ SELECT k, s FROM a WHERE s >= 'foo' select ├── columns: k:1(int!null) s:3(string!null) ├── stats: [rows=330, distinct(1)=330, null(1)=0, distinct(3)=98.265847, null(3)=0] - ├── cost: 1070 + ├── cost: 1070.02 ├── key: (1) ├── fd: (1)-->(3) ├── scan a │ ├── columns: k:1(int!null) s:3(string) │ ├── stats: [rows=1000, distinct(1)=1000, null(1)=0, distinct(3)=100, null(3)=10] - │ ├── cost: 1060 + │ ├── cost: 1060.01 │ ├── key: (1) │ └── fd: (1)-->(3) └── filters diff --git a/pkg/sql/opt/xform/testdata/coster/set b/pkg/sql/opt/xform/testdata/coster/set index d2aee0872c15..470ccb68bac0 100644 --- a/pkg/sql/opt/xform/testdata/coster/set +++ b/pkg/sql/opt/xform/testdata/coster/set @@ -27,18 +27,18 @@ union ├── left columns: a.k:1(int) a.i:2(int) ├── right columns: x:5(int) z:6(int) ├── stats: [rows=1990, distinct(8,9)=1990, null(8,9)=19.92] - ├── cost: 2149.9 + ├── cost: 2149.93 ├── key: (8,9) ├── scan a │ ├── columns: a.k:1(int!null) a.i:2(int) │ ├── stats: [rows=1000, distinct(1,2)=990, null(1,2)=10] - │ ├── cost: 1060 + │ ├── cost: 1060.01 │ ├── key: (1) │ └── fd: (1)-->(2) └── scan b ├── columns: x:5(int) z:6(int!null) ├── stats: [rows=1000, distinct(5,6)=1000, null(5,6)=10] - └── cost: 1050 + └── cost: 1050.01 opt SELECT k, i FROM a UNION ALL SELECT * FROM b @@ -48,17 +48,17 @@ union-all ├── left columns: a.k:1(int) a.i:2(int) ├── right columns: x:5(int) z:6(int) ├── stats: [rows=2000] - ├── cost: 2130 + ├── cost: 2130.03 ├── scan a │ ├── columns: a.k:1(int!null) a.i:2(int) │ ├── stats: [rows=1000] - │ ├── cost: 1060 + │ ├── cost: 1060.01 │ ├── key: (1) │ └── fd: (1)-->(2) └── scan b ├── columns: x:5(int) z:6(int!null) ├── stats: [rows=1000] - └── cost: 1050 + └── cost: 1050.01 opt SELECT k, i FROM a INTERSECT SELECT * FROM b @@ -68,18 +68,18 @@ intersect ├── left columns: k:1(int) i:2(int) ├── right columns: x:5(int) z:6(int) ├── stats: [rows=990, distinct(1,2)=990, null(1,2)=9.91] - ├── cost: 2139.9 + ├── cost: 2139.93 ├── key: (1,2) ├── scan a │ ├── columns: k:1(int!null) i:2(int) │ ├── stats: [rows=1000, distinct(1,2)=990, null(1,2)=10] - │ ├── cost: 1060 + │ ├── cost: 1060.01 │ ├── key: (1) │ └── fd: (1)-->(2) └── scan b ├── columns: x:5(int) z:6(int!null) ├── stats: [rows=1000, distinct(5,6)=1000, null(5,6)=10] - └── cost: 1050 + └── cost: 1050.01 opt SELECT k, i FROM a INTERSECT ALL SELECT * FROM b @@ -89,17 +89,17 @@ intersect-all ├── left columns: k:1(int) i:2(int) ├── right columns: x:5(int) z:6(int) ├── stats: [rows=1000] - ├── cost: 2140 + ├── cost: 2140.03 ├── scan a │ ├── columns: k:1(int!null) i:2(int) │ ├── stats: [rows=1000] - │ ├── cost: 1060 + │ ├── cost: 1060.01 │ ├── key: (1) │ └── fd: (1)-->(2) └── scan b ├── columns: x:5(int) z:6(int!null) ├── stats: [rows=1000] - └── cost: 1050 + └── cost: 1050.01 opt SELECT k, i FROM a EXCEPT SELECT * FROM b @@ -109,18 +109,18 @@ except ├── left columns: k:1(int) i:2(int) ├── right columns: x:5(int) z:6(int) ├── stats: [rows=990, distinct(1,2)=990, null(1,2)=9.91] - ├── cost: 2139.9 + ├── cost: 2139.93 ├── key: (1,2) ├── scan a │ ├── columns: k:1(int!null) i:2(int) │ ├── stats: [rows=1000, distinct(1,2)=990, null(1,2)=10] - │ ├── cost: 1060 + │ ├── cost: 1060.01 │ ├── key: (1) │ └── fd: (1)-->(2) └── scan b ├── columns: x:5(int) z:6(int!null) ├── stats: [rows=1000, distinct(5,6)=1000, null(5,6)=10] - └── cost: 1050 + └── cost: 1050.01 opt SELECT k, i FROM a EXCEPT ALL SELECT * FROM b @@ -130,14 +130,14 @@ except-all ├── left columns: k:1(int) i:2(int) ├── right columns: x:5(int) z:6(int) ├── stats: [rows=1000] - ├── cost: 2140 + ├── cost: 2140.03 ├── scan a │ ├── columns: k:1(int!null) i:2(int) │ ├── stats: [rows=1000] - │ ├── cost: 1060 + │ ├── cost: 1060.01 │ ├── key: (1) │ └── fd: (1)-->(2) └── scan b ├── columns: x:5(int) z:6(int!null) ├── stats: [rows=1000] - └── cost: 1050 + └── cost: 1050.01 diff --git a/pkg/sql/opt/xform/testdata/coster/sort b/pkg/sql/opt/xform/testdata/coster/sort index eca55bcd9f87..e06207ced259 100644 --- a/pkg/sql/opt/xform/testdata/coster/sort +++ b/pkg/sql/opt/xform/testdata/coster/sort @@ -23,12 +23,12 @@ SELECT f FROM a ORDER BY f DESC sort ├── columns: f:2(float!null) ├── stats: [rows=1000] - ├── cost: 1269.31569 + ├── cost: 1269.33569 ├── ordering: -2 └── scan a ├── columns: f:2(float!null) ├── stats: [rows=1000] - └── cost: 1050 + └── cost: 1050.01 # Test sort on 0 rows. opt @@ -38,5 +38,6 @@ values ├── columns: f:2(float) ├── cardinality: [0 - 0] ├── stats: [rows=0] + ├── cost: 0.01 ├── key: () └── fd: ()-->(2) diff --git a/pkg/sql/opt/xform/testdata/coster/values b/pkg/sql/opt/xform/testdata/coster/values index 5d5e3632355e..30816ed06aec 100644 --- a/pkg/sql/opt/xform/testdata/coster/values +++ b/pkg/sql/opt/xform/testdata/coster/values @@ -5,6 +5,6 @@ values ├── columns: column1:1(int) column2:2(int) column3:3(int) ├── cardinality: [2 - 2] ├── stats: [rows=2] - ├── cost: 0.02 + ├── cost: 0.03 ├── (1, 2, 3) [type=tuple{int, int, int}] └── (4, 5, 6) [type=tuple{int, int, int}] diff --git a/pkg/sql/opt/xform/testdata/coster/virtual-scan b/pkg/sql/opt/xform/testdata/coster/virtual-scan index 3d2a8e8ff318..f90a7dd34b82 100644 --- a/pkg/sql/opt/xform/testdata/coster/virtual-scan +++ b/pkg/sql/opt/xform/testdata/coster/virtual-scan @@ -4,11 +4,11 @@ SELECT * FROM information_schema.schemata WHERE SCHEMA_NAME='public' select ├── columns: catalog_name:1(string) schema_name:2(string!null) default_character_set_name:3(string) sql_path:4(string) ├── stats: [rows=10, distinct(2)=1, null(2)=0] - ├── cost: 20 + ├── cost: 20.02 ├── fd: ()-->(2) ├── virtual-scan t.information_schema.schemata │ ├── columns: catalog_name:1(string) schema_name:2(string) default_character_set_name:3(string) sql_path:4(string) │ ├── stats: [rows=1000, distinct(2)=100, null(2)=0] - │ └── cost: 10 + │ └── cost: 10.01 └── filters └── schema_name = 'public' [type=bool, outer=(2), constraints=(/2: [/'public' - /'public']; tight), fd=()-->(2)] diff --git a/pkg/sql/opt/xform/testdata/external/customer b/pkg/sql/opt/xform/testdata/external/customer index 57242d4a4242..4108e2c6e22b 100644 --- a/pkg/sql/opt/xform/testdata/external/customer +++ b/pkg/sql/opt/xform/testdata/external/customer @@ -581,30 +581,23 @@ EXPLAIN SELECT id FROM test ORDER BY id asc LIMIT 10 offset 10000; ---- explain ├── columns: tree:4(string) field:5(string) description:6(string) - └── sort + └── limit ├── columns: id:1(int!null) + ├── internal-ordering: +1 ├── cardinality: [0 - 10] ├── key: (1) ├── ordering: +1 - └── limit - ├── columns: id:1(int!null) - ├── internal-ordering: +1 - ├── cardinality: [0 - 10] - ├── key: (1) - ├── sort - │ ├── columns: id:1(int!null) - │ ├── key: (1) - │ ├── ordering: +1 - │ └── offset - │ ├── columns: id:1(int!null) - │ ├── internal-ordering: +1 - │ ├── key: (1) - │ ├── scan test - │ │ ├── columns: id:1(int!null) - │ │ ├── key: (1) - │ │ └── ordering: +1 - │ └── const: 10000 [type=int] - └── const: 10 [type=int] + ├── offset + │ ├── columns: id:1(int!null) + │ ├── internal-ordering: +1 + │ ├── key: (1) + │ ├── ordering: +1 + │ ├── scan test + │ │ ├── columns: id:1(int!null) + │ │ ├── key: (1) + │ │ └── ordering: +1 + │ └── const: 10000 [type=int] + └── const: 10 [type=int] # ------------------------------------------------------------------------------ # Github Issue 17270: Use the o_ok index rather than the primary index, since diff --git a/pkg/sql/opt/xform/testdata/external/tpcc b/pkg/sql/opt/xform/testdata/external/tpcc index 3fdee03bc2b2..e9db9a43ba1c 100644 --- a/pkg/sql/opt/xform/testdata/external/tpcc +++ b/pkg/sql/opt/xform/testdata/external/tpcc @@ -555,7 +555,7 @@ project ├── columns: w_tax:8(decimal) ├── cardinality: [0 - 1] ├── stats: [rows=1] - ├── cost: 1.12 + ├── cost: 1.14 ├── key: () ├── fd: ()-->(8) ├── prune: (8) @@ -564,7 +564,7 @@ project ├── constraint: /1: [/10 - /10] ├── cardinality: [0 - 1] ├── stats: [rows=1, distinct(1)=1, null(1)=0] - ├── cost: 1.11 + ├── cost: 1.12 ├── key: () ├── fd: ()-->(1,8) ├── prune: (1,8) @@ -579,7 +579,7 @@ project ├── columns: c_discount:16(decimal) c_last:6(string) c_credit:14(string) ├── cardinality: [0 - 1] ├── stats: [rows=3.33333333e-05] - ├── cost: 4.26666667e-05 + ├── cost: 0.0200426667 ├── key: () ├── fd: ()-->(6,14,16) ├── prune: (6,14,16) @@ -588,7 +588,7 @@ project ├── constraint: /3/2/1: [/10/100/50 - /10/100/50] ├── cardinality: [0 - 1] ├── stats: [rows=3.33333333e-05, distinct(1)=3.33333333e-05, null(1)=0, distinct(2)=3.33333333e-05, null(2)=0, distinct(3)=3.33333333e-05, null(3)=0] - ├── cost: 4.23333333e-05 + ├── cost: 0.0100423333 ├── key: () ├── fd: ()-->(1-3,6,14,16) ├── prune: (1-3,6,14,16) @@ -604,7 +604,7 @@ scan item ├── columns: i_price:4(decimal) i_name:3(string) i_data:5(string) [hidden: i_id:1(int!null)] ├── constraint: /1: [/25 - /25] [/50 - /50] [/75 - /75] [/100 - /100] [/125 - /125] [/150 - /150] [/175 - /175] [/200 - /200] [/225 - /225] [/250 - /250] [/275 - /275] [/300 - /300] ├── stats: [rows=12, distinct(1)=12, null(1)=0] - ├── cost: 13.08 + ├── cost: 13.09 ├── key: (1) ├── fd: (1)-->(3-5) ├── ordering: +1 @@ -620,7 +620,7 @@ ORDER BY s_i_id project ├── columns: s_quantity:3(int) s_ytd:14(int) s_order_cnt:15(int) s_remote_cnt:16(int) s_data:17(string) s_dist_05:8(string) [hidden: s_i_id:1(int!null)] ├── stats: [rows=5] - ├── cost: 6.3 + ├── cost: 6.32 ├── key: (1) ├── fd: (1)-->(3,8,14-17) ├── ordering: +1 @@ -630,7 +630,7 @@ project ├── columns: s_i_id:1(int!null) s_w_id:2(int!null) s_quantity:3(int) s_dist_05:8(string) s_ytd:14(int) s_order_cnt:15(int) s_remote_cnt:16(int) s_data:17(string) ├── constraint: /2/1: [/4/900 - /4/900] [/4/1000 - /4/1000] [/4/1100 - /4/1100] [/4/1400 - /4/1400] [/4/1500 - /4/1500] ├── stats: [rows=5, distinct(1)=5, null(1)=0, distinct(2)=1, null(2)=0] - ├── cost: 6.25 + ├── cost: 6.26 ├── key: (1) ├── fd: ()-->(2), (1)-->(3,8,14-17) ├── ordering: +1 opt(2) [provided: +1] @@ -655,7 +655,7 @@ ORDER BY c_first ASC project ├── columns: c_id:1(int!null) [hidden: c_first:4(string)] ├── stats: [rows=3.3e-05] - ├── cost: 3.663e-05 + ├── cost: 0.02003663 ├── key: (1) ├── fd: (1)-->(4) ├── ordering: +4 @@ -664,7 +664,7 @@ project ├── columns: c_id:1(int!null) c_d_id:2(int!null) c_w_id:3(int!null) c_first:4(string) c_last:6(string!null) ├── constraint: /3/2/6/4/1: [/10/100/'Smith' - /10/100/'Smith'] ├── stats: [rows=3.3e-05, distinct(1)=3.3e-05, null(1)=0, distinct(2)=3.3e-05, null(2)=0, distinct(3)=3.3e-05, null(3)=0, distinct(6)=3.3e-05, null(6)=0] - ├── cost: 3.63e-05 + ├── cost: 0.0100363 ├── key: (1) ├── fd: ()-->(2,3,6), (1)-->(4) ├── ordering: +4 opt(2,3,6) [provided: +4] @@ -689,7 +689,7 @@ project ├── columns: c_balance:17(decimal) c_first:4(string) c_middle:5(string) c_last:6(string) ├── cardinality: [0 - 1] ├── stats: [rows=3.33333333e-05] - ├── cost: 4.3e-05 + ├── cost: 0.020043 ├── key: () ├── fd: ()-->(4-6,17) ├── prune: (4-6,17) @@ -698,7 +698,7 @@ project ├── constraint: /3/2/1: [/10/100/50 - /10/100/50] ├── cardinality: [0 - 1] ├── stats: [rows=3.33333333e-05, distinct(1)=3.33333333e-05, null(1)=0, distinct(2)=3.33333333e-05, null(2)=0, distinct(3)=3.33333333e-05, null(3)=0] - ├── cost: 4.26666667e-05 + ├── cost: 0.0100426667 ├── key: () ├── fd: ()-->(1-6,17) ├── prune: (1-6,17) @@ -713,7 +713,7 @@ ORDER BY c_first ASC project ├── columns: c_id:1(int!null) c_balance:17(decimal) c_first:4(string) c_middle:5(string) ├── stats: [rows=3.3e-05] - ├── cost: 0.0001782 + ├── cost: 0.0301782 ├── key: (1) ├── fd: (1)-->(4,5,17) ├── ordering: +4 @@ -721,7 +721,7 @@ project └── index-join customer ├── columns: c_id:1(int!null) c_d_id:2(int!null) c_w_id:3(int!null) c_first:4(string) c_middle:5(string) c_last:6(string!null) c_balance:17(decimal) ├── stats: [rows=3.3e-05, distinct(1)=3.3e-05, null(1)=0, distinct(2)=3.3e-05, null(2)=0, distinct(3)=3.3e-05, null(3)=0, distinct(6)=3.3e-05, null(6)=0] - ├── cost: 0.00017787 + ├── cost: 0.02017787 ├── key: (1) ├── fd: ()-->(2,3,6), (1)-->(4,5,17) ├── ordering: +4 opt(2,3,6) [provided: +4] @@ -730,7 +730,7 @@ project ├── columns: c_id:1(int!null) c_d_id:2(int!null) c_w_id:3(int!null) c_first:4(string) c_last:6(string!null) ├── constraint: /3/2/6/4/1: [/10/100/'Smith' - /10/100/'Smith'] ├── stats: [rows=3.3e-05, distinct(1)=3.3e-05, null(1)=0, distinct(2)=3.3e-05, null(2)=0, distinct(3)=3.3e-05, null(3)=0, distinct(6)=3.3e-05, null(6)=0] - ├── cost: 3.63e-05 + ├── cost: 0.0100363 ├── key: (1) ├── fd: ()-->(2,3,6), (1)-->(4) ├── ordering: +4 opt(2,3,6) [provided: +4] @@ -748,7 +748,7 @@ project ├── columns: o_id:1(int!null) o_entry_d:5(timestamp) o_carrier_id:6(int) ├── cardinality: [0 - 1] ├── stats: [rows=3.3e-05] - ├── cost: 0.00017292 + ├── cost: 0.03017292 ├── key: () ├── fd: ()-->(1,5,6) ├── prune: (1,5,6) @@ -756,7 +756,7 @@ project ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) o_c_id:4(int!null) o_entry_d:5(timestamp) o_carrier_id:6(int) ├── cardinality: [0 - 1] ├── stats: [rows=3.3e-05] - ├── cost: 0.00017259 + ├── cost: 0.02017259 ├── key: () ├── fd: ()-->(1-6) ├── interesting orderings: (+3,+2,-1) (+3,+2,+4,+1) @@ -765,7 +765,7 @@ project ├── constraint: /3/2/4/1: [/10/100/50 - /10/100/50] ├── limit: 1(rev) ├── stats: [rows=3.3e-05, distinct(1)=3.3e-05, null(1)=0, distinct(2)=3.3e-05, null(2)=0, distinct(3)=3.3e-05, null(3)=0, distinct(4)=3.3e-05, null(4)=0] - ├── cost: 3.564e-05 + ├── cost: 0.01003564 ├── key: () ├── fd: ()-->(1-4) ├── prune: (1-4) @@ -779,14 +779,14 @@ WHERE ol_w_id = 10 AND ol_d_id = 100 AND ol_o_id = 1000 project ├── columns: ol_i_id:5(int!null) ol_supply_w_id:6(int) ol_quantity:8(int) ol_amount:9(decimal) ol_delivery_d:7(timestamp) ├── stats: [rows=1e-05] - ├── cost: 1.19e-05 + ├── cost: 0.0200119 ├── prune: (5-9) ├── interesting orderings: (+6) └── scan order_line ├── columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null) ol_i_id:5(int!null) ol_supply_w_id:6(int) ol_delivery_d:7(timestamp) ol_quantity:8(int) ol_amount:9(decimal) ├── constraint: /3/2/-1/4: [/10/100/1000 - /10/100/1000] ├── stats: [rows=1e-05, distinct(1)=1e-05, null(1)=0, distinct(2)=1e-05, null(2)=0, distinct(3)=1e-05, null(3)=0, distinct(5)=1e-05, null(5)=0] - ├── cost: 1.18e-05 + ├── cost: 0.0100118 ├── fd: ()-->(1-3) ├── prune: (1-3,5-9) └── interesting orderings: (+3,+2,-1) (+6,+2,+3,+1) @@ -818,7 +818,7 @@ project ├── columns: no_o_id:1(int!null) ├── cardinality: [0 - 1] ├── stats: [rows=1] - ├── cost: 1.07 + ├── cost: 1.09 ├── key: () ├── fd: ()-->(1) ├── prune: (1) @@ -827,7 +827,7 @@ project ├── constraint: /3/2/-1: [/10/100 - /10/100] ├── limit: 1(rev) ├── stats: [rows=1] - ├── cost: 1.06 + ├── cost: 1.07 ├── key: () ├── fd: ()-->(1-3) ├── prune: (1-3) @@ -842,7 +842,7 @@ scalar-group-by ├── columns: sum:11(decimal) ├── cardinality: [1 - 1] ├── stats: [rows=1] - ├── cost: 0.0100115 + ├── cost: 0.0300115 ├── key: () ├── fd: ()-->(11) ├── prune: (11) @@ -850,7 +850,7 @@ scalar-group-by │ ├── columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null) ol_amount:9(decimal) │ ├── constraint: /3/2/-1/4: [/10/100/1000 - /10/100/1000] │ ├── stats: [rows=1e-05, distinct(1)=1e-05, null(1)=0, distinct(2)=1e-05, null(2)=0, distinct(3)=1e-05, null(3)=0] - │ ├── cost: 1.14e-05 + │ ├── cost: 0.0100114 │ ├── fd: ()-->(1-3) │ ├── prune: (1-3,9) │ └── interesting orderings: (+3,+2,-1) @@ -875,7 +875,7 @@ project ├── columns: d_next_o_id:11(int) ├── cardinality: [0 - 1] ├── stats: [rows=1] - ├── cost: 1.15 + ├── cost: 1.17 ├── key: () ├── fd: ()-->(11) ├── prune: (11) @@ -884,7 +884,7 @@ project ├── constraint: /2/1: [/10/100 - /10/100] ├── cardinality: [0 - 1] ├── stats: [rows=1, distinct(1)=1, null(1)=0, distinct(2)=1, null(2)=0] - ├── cost: 1.14 + ├── cost: 1.15 ├── key: () ├── fd: ()-->(1,2,11) ├── prune: (1,2,11) @@ -904,7 +904,7 @@ scalar-group-by ├── columns: count:28(int) ├── cardinality: [1 - 1] ├── stats: [rows=1] - ├── cost: 1.79111111 + ├── cost: 1.82111111 ├── key: () ├── fd: ()-->(28) ├── prune: (28) @@ -912,14 +912,14 @@ scalar-group-by │ ├── columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null) ol_i_id:5(int!null) s_i_id:11(int!null) s_w_id:12(int!null) s_quantity:13(int!null) │ ├── key columns: [3 5] = [12 11] │ ├── stats: [rows=1, distinct(1)=0.11109736, null(1)=0, distinct(2)=0.111097416, null(2)=0, distinct(3)=0.111111111, null(3)=0, distinct(5)=0.111111056, null(5)=0, distinct(11)=0.111111056, null(11)=0, distinct(12)=0.111111111, null(12)=0, distinct(13)=1, null(13)=0] - │ ├── cost: 1.77111111 + │ ├── cost: 1.79111111 │ ├── fd: ()-->(2,3,12), (11)-->(13), (5)==(11), (11)==(5), (3)==(12), (12)==(3) │ ├── interesting orderings: (+3,+2,-1) │ ├── scan order_line │ │ ├── columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null) ol_i_id:5(int!null) │ │ ├── constraint: /3/2/-1/4: [/10/100/999 - /10/100/980] │ │ ├── stats: [rows=0.111111111, distinct(1)=0.111111056, null(1)=0, distinct(2)=0.111111111, null(2)=0, distinct(3)=0.111111111, null(3)=0, distinct(5)=0.111111056, null(5)=0] - │ │ ├── cost: 0.126666667 + │ │ ├── cost: 0.136666667 │ │ ├── fd: ()-->(2,3) │ │ ├── prune: (5) │ │ └── interesting orderings: (+3,+2,-1) @@ -957,7 +957,7 @@ scalar-group-by ├── columns: count:22(int) ├── cardinality: [1 - 1] ├── stats: [rows=1] - ├── cost: 126.476 + ├── cost: 126.526 ├── key: () ├── fd: ()-->(22) ├── prune: (22) @@ -966,13 +966,13 @@ scalar-group-by │ ├── left ordering: +1 │ ├── right ordering: +11 │ ├── stats: [rows=3.3, distinct(1)=3.3, null(1)=0, distinct(9)=0.966296553, null(9)=0, distinct(11)=3.3, null(11)=0, distinct(21)=2.87528606, null(21)=0] - │ ├── cost: 126.433 + │ ├── cost: 126.473 │ ├── key: (11) │ ├── fd: (1)-->(9), (11)-->(21), (1)==(11), (11)==(1) │ ├── scan warehouse │ │ ├── columns: w_id:1(int!null) w_ytd:9(decimal) │ │ ├── stats: [rows=10, distinct(1)=10, null(1)=0, distinct(9)=1, null(9)=0.1] - │ │ ├── cost: 11.1 + │ │ ├── cost: 11.11 │ │ ├── key: (1) │ │ ├── fd: (1)-->(9) │ │ ├── ordering: +1 @@ -982,7 +982,7 @@ scalar-group-by │ │ ├── columns: d_w_id:11(int!null) sum:21(decimal) │ │ ├── grouping columns: d_w_id:11(int!null) │ │ ├── stats: [rows=10, distinct(11)=10, null(11)=0, distinct(21)=10, null(21)=0] - │ │ ├── cost: 115.1 + │ │ ├── cost: 115.12 │ │ ├── key: (11) │ │ ├── fd: (11)-->(21) │ │ ├── ordering: +11 @@ -991,7 +991,7 @@ scalar-group-by │ │ ├── scan district │ │ │ ├── columns: d_w_id:11(int!null) d_ytd:19(decimal) │ │ │ ├── stats: [rows=100, distinct(11)=10, null(11)=0] - │ │ │ ├── cost: 113 + │ │ │ ├── cost: 113.01 │ │ │ ├── ordering: +11 │ │ │ ├── prune: (11,19) │ │ │ └── interesting orderings: (+11) @@ -1013,7 +1013,7 @@ ORDER BY d_w_id, d_id scan district ├── columns: d_next_o_id:11(int) [hidden: d_id:1(int!null) d_w_id:2(int!null)] ├── stats: [rows=100] - ├── cost: 114 + ├── cost: 114.01 ├── key: (1,2) ├── fd: (1,2)-->(11) ├── ordering: +2,+1 @@ -1030,7 +1030,7 @@ group-by ├── columns: max:4(int) [hidden: no_d_id:2(int!null) no_w_id:3(int!null)] ├── grouping columns: no_d_id:2(int!null) no_w_id:3(int!null) ├── stats: [rows=100, distinct(2,3)=100, null(2,3)=0] - ├── cost: 98101 + ├── cost: 98101.02 ├── key: (2,3) ├── fd: (2,3)-->(4) ├── ordering: +3,+2 @@ -1039,7 +1039,7 @@ group-by ├── scan new_order │ ├── columns: no_o_id:1(int!null) no_d_id:2(int!null) no_w_id:3(int!null) │ ├── stats: [rows=90000, distinct(2,3)=100, null(2,3)=0] - │ ├── cost: 95400 + │ ├── cost: 95400.01 │ ├── key: (1-3) │ ├── ordering: +3,+2 │ ├── prune: (1-3) @@ -1058,7 +1058,7 @@ group-by ├── columns: max:9(int) [hidden: o_d_id:2(int!null) o_w_id:3(int!null)] ├── grouping columns: o_d_id:2(int!null) o_w_id:3(int!null) ├── stats: [rows=100, distinct(2,3)=100, null(2,3)=0] - ├── cost: 330001 + ├── cost: 330001.02 ├── key: (2,3) ├── fd: (2,3)-->(9) ├── ordering: +3,+2 @@ -1067,7 +1067,7 @@ group-by ├── scan order@order_idx │ ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) │ ├── stats: [rows=300000, distinct(2,3)=100, null(2,3)=0] - │ ├── cost: 321000 + │ ├── cost: 321000.01 │ ├── key: (1-3) │ ├── ordering: +3,+2 │ ├── prune: (1-3) @@ -1090,14 +1090,14 @@ scalar-group-by ├── columns: count:8(int) ├── cardinality: [1 - 1] ├── stats: [rows=1] - ├── cost: 99902.3433 + ├── cost: 99902.3833 ├── key: () ├── fd: ()-->(8) ├── prune: (8) ├── select │ ├── columns: no_d_id:2(int!null) no_w_id:3(int!null) max:4(int) min:5(int) count_rows:6(int) │ ├── stats: [rows=33.3333333, distinct(2)=33.3333333, null(2)=0, distinct(3)=9.8265847, null(3)=0] - │ ├── cost: 99902 + │ ├── cost: 99902.03 │ ├── key: (2,3) │ ├── fd: (2,3)-->(4-6) │ ├── interesting orderings: (+3,+2) @@ -1106,7 +1106,7 @@ scalar-group-by │ │ ├── grouping columns: no_d_id:2(int!null) no_w_id:3(int!null) │ │ ├── internal-ordering: +3,+2 │ │ ├── stats: [rows=100, distinct(2)=9000, null(2)=0, distinct(3)=10, null(3)=0, distinct(2,3)=100, null(2,3)=0] - │ │ ├── cost: 99901 + │ │ ├── cost: 99901.02 │ │ ├── key: (2,3) │ │ ├── fd: (2,3)-->(4-6) │ │ ├── prune: (4-6) @@ -1114,7 +1114,7 @@ scalar-group-by │ │ ├── scan new_order │ │ │ ├── columns: no_o_id:1(int!null) no_d_id:2(int!null) no_w_id:3(int!null) │ │ │ ├── stats: [rows=90000, distinct(2)=9000, null(2)=0, distinct(3)=10, null(3)=0, distinct(2,3)=100, null(2,3)=0] - │ │ │ ├── cost: 95400 + │ │ │ ├── cost: 95400.01 │ │ │ ├── key: (1-3) │ │ │ ├── ordering: +3,+2 │ │ │ ├── prune: (1-3) @@ -1146,7 +1146,7 @@ group-by ├── columns: sum:9(decimal) [hidden: o_d_id:2(int!null) o_w_id:3(int!null)] ├── grouping columns: o_d_id:2(int!null) o_w_id:3(int!null) ├── stats: [rows=100, distinct(2,3)=100, null(2,3)=0] - ├── cost: 342001 + ├── cost: 342001.02 ├── key: (2,3) ├── fd: (2,3)-->(9) ├── ordering: +3,+2 @@ -1155,7 +1155,7 @@ group-by ├── scan order │ ├── columns: o_d_id:2(int!null) o_w_id:3(int!null) o_ol_cnt:7(int) │ ├── stats: [rows=300000, distinct(2,3)=100, null(2,3)=0] - │ ├── cost: 333000 + │ ├── cost: 333000.01 │ ├── ordering: +3,+2 │ ├── prune: (2,3,7) │ └── interesting orderings: (+3,+2) @@ -1172,7 +1172,7 @@ ORDER BY ol_w_id, ol_d_id sort ├── columns: count:11(int) [hidden: ol_d_id:2(int!null) ol_w_id:3(int!null)] ├── stats: [rows=100, distinct(2,3)=100, null(2,3)=0] - ├── cost: 1110017.05 + ├── cost: 1110017.08 ├── key: (2,3) ├── fd: (2,3)-->(11) ├── ordering: +3,+2 @@ -1181,14 +1181,14 @@ sort ├── columns: ol_d_id:2(int!null) ol_w_id:3(int!null) count_rows:11(int) ├── grouping columns: ol_d_id:2(int!null) ol_w_id:3(int!null) ├── stats: [rows=100, distinct(2,3)=100, null(2,3)=0] - ├── cost: 1110001 + ├── cost: 1110001.02 ├── key: (2,3) ├── fd: (2,3)-->(11) ├── prune: (11) ├── scan order_line@order_line_fk │ ├── columns: ol_d_id:2(int!null) ol_w_id:3(int!null) │ ├── stats: [rows=1000000, distinct(2,3)=100, null(2,3)=0] - │ ├── cost: 1070000 + │ ├── cost: 1070000.01 │ ├── prune: (2,3) │ └── interesting orderings: (+3,+2) └── aggregations @@ -1204,25 +1204,25 @@ except-all ├── left columns: no_w_id:3(int!null) no_d_id:2(int!null) no_o_id:1(int!null) ├── right columns: o_w_id:6(int) o_d_id:5(int) o_id:4(int) ├── stats: [rows=90000] - ├── cost: 424200.198 + ├── cost: 424200.248 ├── scan new_order │ ├── columns: no_o_id:1(int!null) no_d_id:2(int!null) no_w_id:3(int!null) │ ├── stats: [rows=90000] - │ ├── cost: 95400 + │ ├── cost: 95400.01 │ ├── key: (1-3) │ ├── prune: (1-3) │ └── interesting orderings: (+3,+2,-1) └── project ├── columns: o_id:4(int!null) o_d_id:5(int!null) o_w_id:6(int!null) ├── stats: [rows=9.90033333] - ├── cost: 327000.099 + ├── cost: 327000.129 ├── key: (4-6) ├── prune: (4-6) ├── interesting orderings: (+6,+5,-4) └── select ├── columns: o_id:4(int!null) o_d_id:5(int!null) o_w_id:6(int!null) o_carrier_id:9(int) ├── stats: [rows=9.90033333, distinct(4)=9.90033333, null(4)=0, distinct(5)=9.90033333, null(5)=0, distinct(6)=6.3212669, null(6)=0, distinct(9)=1, null(9)=9.90033333] - ├── cost: 327000 + ├── cost: 327000.02 ├── key: (4-6) ├── fd: ()-->(9) ├── prune: (4-6) @@ -1230,7 +1230,7 @@ except-all ├── scan order@order_idx │ ├── columns: o_id:4(int!null) o_d_id:5(int!null) o_w_id:6(int!null) o_carrier_id:9(int) │ ├── stats: [rows=300000, distinct(4)=30000, null(4)=0, distinct(5)=30000, null(5)=0, distinct(6)=10, null(6)=0, distinct(9)=30000, null(9)=3000] - │ ├── cost: 324000 + │ ├── cost: 324000.01 │ ├── key: (4-6) │ ├── fd: (4-6)-->(9) │ ├── prune: (4-6,9) @@ -1250,18 +1250,18 @@ except-all ├── left columns: o_w_id:3(int!null) o_d_id:2(int!null) o_id:1(int!null) ├── right columns: no_w_id:11(int) no_d_id:10(int) no_o_id:9(int) ├── stats: [rows=9.90033333] - ├── cost: 423300.297 + ├── cost: 423300.347 ├── project │ ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) │ ├── stats: [rows=9.90033333] - │ ├── cost: 327000.099 + │ ├── cost: 327000.129 │ ├── key: (1-3) │ ├── prune: (1-3) │ ├── interesting orderings: (+3,+2,-1) │ └── select │ ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) o_carrier_id:6(int) │ ├── stats: [rows=9.90033333, distinct(1)=9.90033333, null(1)=0, distinct(2)=9.90033333, null(2)=0, distinct(3)=6.3212669, null(3)=0, distinct(6)=1, null(6)=9.90033333] - │ ├── cost: 327000 + │ ├── cost: 327000.02 │ ├── key: (1-3) │ ├── fd: ()-->(6) │ ├── prune: (1-3) @@ -1269,7 +1269,7 @@ except-all │ ├── scan order@order_idx │ │ ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) o_carrier_id:6(int) │ │ ├── stats: [rows=300000, distinct(1)=30000, null(1)=0, distinct(2)=30000, null(2)=0, distinct(3)=10, null(3)=0, distinct(6)=30000, null(6)=3000] - │ │ ├── cost: 324000 + │ │ ├── cost: 324000.01 │ │ ├── key: (1-3) │ │ ├── fd: (1-3)-->(6) │ │ ├── prune: (1-3,6) @@ -1281,7 +1281,7 @@ except-all └── scan new_order ├── columns: no_o_id:9(int!null) no_d_id:10(int!null) no_w_id:11(int!null) ├── stats: [rows=90000] - ├── cost: 95400 + ├── cost: 95400.01 ├── key: (9-11) ├── prune: (9-11) └── interesting orderings: (+11,+10,-9) @@ -1305,11 +1305,11 @@ except-all ├── left columns: o_w_id:3(int!null) o_d_id:2(int!null) o_id:1(int!null) o_ol_cnt:7(int) ├── right columns: ol_w_id:11(int) ol_d_id:10(int) ol_o_id:9(int) count_rows:19(int) ├── stats: [rows=300000] - ├── cost: 1474000 + ├── cost: 1474000.04 ├── scan order │ ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) o_ol_cnt:7(int) │ ├── stats: [rows=300000] - │ ├── cost: 336000 + │ ├── cost: 336000.01 │ ├── key: (1-3) │ ├── fd: (1-3)-->(7) │ ├── prune: (1-3,7) @@ -1318,7 +1318,7 @@ except-all ├── columns: ol_o_id:9(int!null) ol_d_id:10(int!null) ol_w_id:11(int!null) count_rows:19(int) ├── grouping columns: ol_o_id:9(int!null) ol_d_id:10(int!null) ol_w_id:11(int!null) ├── stats: [rows=100000, distinct(9-11)=100000, null(9-11)=0] - ├── cost: 1131000 + ├── cost: 1131000.02 ├── key: (9-11) ├── fd: (9-11)-->(19) ├── prune: (19) @@ -1326,7 +1326,7 @@ except-all ├── scan order_line@order_line_fk │ ├── columns: ol_o_id:9(int!null) ol_d_id:10(int!null) ol_w_id:11(int!null) │ ├── stats: [rows=1000000, distinct(9-11)=100000, null(9-11)=0] - │ ├── cost: 1080000 + │ ├── cost: 1080000.01 │ ├── prune: (9-11) │ └── interesting orderings: (+11,+10,-9) └── aggregations @@ -1351,12 +1351,12 @@ except-all ├── left columns: ol_w_id:3(int!null) ol_d_id:2(int!null) ol_o_id:1(int!null) count_rows:11(int) ├── right columns: o_w_id:14(int) o_d_id:13(int) o_id:12(int) o_ol_cnt:18(int) ├── stats: [rows=100000] - ├── cost: 1472000 + ├── cost: 1472000.04 ├── group-by │ ├── columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null) count_rows:11(int) │ ├── grouping columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null) │ ├── stats: [rows=100000, distinct(1-3)=100000, null(1-3)=0] - │ ├── cost: 1131000 + │ ├── cost: 1131000.02 │ ├── key: (1-3) │ ├── fd: (1-3)-->(11) │ ├── prune: (11) @@ -1364,7 +1364,7 @@ except-all │ ├── scan order_line@order_line_fk │ │ ├── columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null) │ │ ├── stats: [rows=1000000, distinct(1-3)=100000, null(1-3)=0] - │ │ ├── cost: 1080000 + │ │ ├── cost: 1080000.01 │ │ ├── prune: (1-3) │ │ └── interesting orderings: (+3,+2,-1) │ └── aggregations @@ -1372,7 +1372,7 @@ except-all └── scan order ├── columns: o_id:12(int!null) o_d_id:13(int!null) o_w_id:14(int!null) o_ol_cnt:18(int) ├── stats: [rows=300000] - ├── cost: 336000 + ├── cost: 336000.01 ├── key: (12-14) ├── fd: (12-14)-->(18) ├── prune: (12-14,18) @@ -1399,32 +1399,32 @@ scalar-group-by ├── columns: count:19(int) ├── cardinality: [1 - 1] ├── stats: [rows=1] - ├── cost: 1477000.96 + ├── cost: 1477001.05 ├── key: () ├── fd: ()-->(19) ├── prune: (19) ├── select │ ├── columns: o_id:1(int) o_d_id:2(int) o_w_id:3(int) ol_o_id:9(int) ol_d_id:10(int) ol_w_id:11(int) │ ├── stats: [rows=6.54741364] - │ ├── cost: 1477000.89 + │ ├── cost: 1477000.97 │ ├── interesting orderings: (+3,+2,-1) (+11,+10,-9) │ ├── full-join │ │ ├── columns: o_id:1(int) o_d_id:2(int) o_w_id:3(int) ol_o_id:9(int) ol_d_id:10(int) ol_w_id:11(int) │ │ ├── stats: [rows=19.6422409] - │ │ ├── cost: 1477000.69 + │ │ ├── cost: 1477000.76 │ │ ├── reject-nulls: (1-3,9-11) │ │ ├── interesting orderings: (+3,+2,-1) (+11,+10,-9) │ │ ├── project │ │ │ ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) │ │ │ ├── stats: [rows=9.90033333, distinct(1)=9.90033333, null(1)=0, distinct(2)=9.90033333, null(2)=0, distinct(3)=6.3212669, null(3)=0] - │ │ │ ├── cost: 327000.099 + │ │ │ ├── cost: 327000.129 │ │ │ ├── key: (1-3) │ │ │ ├── prune: (1-3) │ │ │ ├── interesting orderings: (+3,+2,-1) │ │ │ └── select │ │ │ ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) o_carrier_id:6(int) │ │ │ ├── stats: [rows=9.90033333, distinct(1)=9.90033333, null(1)=0, distinct(2)=9.90033333, null(2)=0, distinct(3)=6.3212669, null(3)=0, distinct(6)=1, null(6)=9.90033333] - │ │ │ ├── cost: 327000 + │ │ │ ├── cost: 327000.02 │ │ │ ├── key: (1-3) │ │ │ ├── fd: ()-->(6) │ │ │ ├── prune: (1-3) @@ -1432,7 +1432,7 @@ scalar-group-by │ │ │ ├── scan order@order_idx │ │ │ │ ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) o_carrier_id:6(int) │ │ │ │ ├── stats: [rows=300000, distinct(1)=30000, null(1)=0, distinct(2)=30000, null(2)=0, distinct(3)=10, null(3)=0, distinct(6)=30000, null(6)=3000] - │ │ │ │ ├── cost: 324000 + │ │ │ │ ├── cost: 324000.01 │ │ │ │ ├── key: (1-3) │ │ │ │ ├── fd: (1-3)-->(6) │ │ │ │ ├── prune: (1-3,6) @@ -1444,20 +1444,20 @@ scalar-group-by │ │ ├── project │ │ │ ├── columns: ol_o_id:9(int!null) ol_d_id:10(int!null) ol_w_id:11(int!null) │ │ │ ├── stats: [rows=9.9001, distinct(9)=9.9001, null(9)=0, distinct(10)=9.9001, null(10)=0, distinct(11)=6.32122398, null(11)=0] - │ │ │ ├── cost: 1150000.1 + │ │ │ ├── cost: 1150000.13 │ │ │ ├── prune: (9-11) │ │ │ ├── interesting orderings: (+11,+10,-9) │ │ │ └── select │ │ │ ├── columns: ol_o_id:9(int!null) ol_d_id:10(int!null) ol_w_id:11(int!null) ol_delivery_d:15(timestamp) │ │ │ ├── stats: [rows=9.9001, distinct(9)=9.9001, null(9)=0, distinct(10)=9.9001, null(10)=0, distinct(11)=6.32122398, null(11)=0, distinct(15)=1, null(15)=9.9001] - │ │ │ ├── cost: 1150000 + │ │ │ ├── cost: 1150000.02 │ │ │ ├── fd: ()-->(15) │ │ │ ├── prune: (9-11) │ │ │ ├── interesting orderings: (+11,+10,-9) │ │ │ ├── scan order_line │ │ │ │ ├── columns: ol_o_id:9(int!null) ol_d_id:10(int!null) ol_w_id:11(int!null) ol_delivery_d:15(timestamp) │ │ │ │ ├── stats: [rows=1000000, distinct(9)=100000, null(9)=0, distinct(10)=100000, null(10)=0, distinct(11)=10, null(11)=0, distinct(15)=100000, null(15)=10000] - │ │ │ │ ├── cost: 1140000 + │ │ │ │ ├── cost: 1140000.01 │ │ │ │ ├── prune: (9-11,15) │ │ │ │ └── interesting orderings: (+11,+10,-9) │ │ │ └── filters diff --git a/pkg/sql/opt/xform/testdata/external/tpcc-no-stats b/pkg/sql/opt/xform/testdata/external/tpcc-no-stats index 3742f2e98993..bfa5b5734f6e 100644 --- a/pkg/sql/opt/xform/testdata/external/tpcc-no-stats +++ b/pkg/sql/opt/xform/testdata/external/tpcc-no-stats @@ -360,7 +360,7 @@ project ├── columns: w_tax:8(decimal) ├── cardinality: [0 - 1] ├── stats: [rows=1] - ├── cost: 1.12 + ├── cost: 1.14 ├── key: () ├── fd: ()-->(8) ├── prune: (8) @@ -369,7 +369,7 @@ project ├── constraint: /1: [/10 - /10] ├── cardinality: [0 - 1] ├── stats: [rows=1, distinct(1)=1, null(1)=0] - ├── cost: 1.11 + ├── cost: 1.12 ├── key: () ├── fd: ()-->(1,8) ├── prune: (1,8) @@ -384,7 +384,7 @@ project ├── columns: c_discount:16(decimal) c_last:6(string) c_credit:14(string) ├── cardinality: [0 - 1] ├── stats: [rows=0.001] - ├── cost: 0.00128 + ├── cost: 0.02128 ├── key: () ├── fd: ()-->(6,14,16) ├── prune: (6,14,16) @@ -393,7 +393,7 @@ project ├── constraint: /3/2/1: [/10/100/50 - /10/100/50] ├── cardinality: [0 - 1] ├── stats: [rows=0.001, distinct(1)=0.001, null(1)=0, distinct(2)=0.001, null(2)=0, distinct(3)=0.001, null(3)=0] - ├── cost: 0.00127 + ├── cost: 0.01127 ├── key: () ├── fd: ()-->(1-3,6,14,16) ├── prune: (1-3,6,14,16) @@ -409,7 +409,7 @@ scan item ├── columns: i_price:4(decimal) i_name:3(string) i_data:5(string) [hidden: i_id:1(int!null)] ├── constraint: /1: [/25 - /25] [/50 - /50] [/75 - /75] [/100 - /100] [/125 - /125] [/150 - /150] [/175 - /175] [/200 - /200] [/225 - /225] [/250 - /250] [/275 - /275] [/300 - /300] ├── stats: [rows=12, distinct(1)=12, null(1)=0] - ├── cost: 13.08 + ├── cost: 13.09 ├── key: (1) ├── fd: (1)-->(3-5) ├── ordering: +1 @@ -425,7 +425,7 @@ ORDER BY s_i_id project ├── columns: s_quantity:3(int) s_ytd:14(int) s_order_cnt:15(int) s_remote_cnt:16(int) s_data:17(string) s_dist_05:8(string) [hidden: s_i_id:1(int!null)] ├── stats: [rows=0.5] - ├── cost: 0.63 + ├── cost: 0.65 ├── key: (1) ├── fd: (1)-->(3,8,14-17) ├── ordering: +1 @@ -435,7 +435,7 @@ project ├── columns: s_i_id:1(int!null) s_w_id:2(int!null) s_quantity:3(int) s_dist_05:8(string) s_ytd:14(int) s_order_cnt:15(int) s_remote_cnt:16(int) s_data:17(string) ├── constraint: /2/1: [/4/900 - /4/900] [/4/1000 - /4/1000] [/4/1100 - /4/1100] [/4/1400 - /4/1400] [/4/1500 - /4/1500] ├── stats: [rows=0.5, distinct(1)=0.5, null(1)=0, distinct(2)=0.5, null(2)=0] - ├── cost: 0.625 + ├── cost: 0.635 ├── key: (1) ├── fd: ()-->(2), (1)-->(3,8,14-17) ├── ordering: +1 opt(2) [provided: +1] @@ -460,7 +460,7 @@ ORDER BY c_first ASC project ├── columns: c_id:1(int!null) [hidden: c_first:4(string)] ├── stats: [rows=0.00099] - ├── cost: 0.0010989 + ├── cost: 0.0210989 ├── key: (1) ├── fd: (1)-->(4) ├── ordering: +4 @@ -469,7 +469,7 @@ project ├── columns: c_id:1(int!null) c_d_id:2(int!null) c_w_id:3(int!null) c_first:4(string) c_last:6(string!null) ├── constraint: /3/2/6/4/1: [/10/100/'Smith' - /10/100/'Smith'] ├── stats: [rows=0.00099, distinct(1)=0.00099, null(1)=0, distinct(2)=0.00099, null(2)=0, distinct(3)=0.00099, null(3)=0, distinct(6)=0.00099, null(6)=0] - ├── cost: 0.001089 + ├── cost: 0.011089 ├── key: (1) ├── fd: ()-->(2,3,6), (1)-->(4) ├── ordering: +4 opt(2,3,6) [provided: +4] @@ -494,7 +494,7 @@ project ├── columns: c_balance:17(decimal) c_first:4(string) c_middle:5(string) c_last:6(string) ├── cardinality: [0 - 1] ├── stats: [rows=0.001] - ├── cost: 0.00129 + ├── cost: 0.02129 ├── key: () ├── fd: ()-->(4-6,17) ├── prune: (4-6,17) @@ -503,7 +503,7 @@ project ├── constraint: /3/2/1: [/10/100/50 - /10/100/50] ├── cardinality: [0 - 1] ├── stats: [rows=0.001, distinct(1)=0.001, null(1)=0, distinct(2)=0.001, null(2)=0, distinct(3)=0.001, null(3)=0] - ├── cost: 0.00128 + ├── cost: 0.01128 ├── key: () ├── fd: ()-->(1-6,17) ├── prune: (1-6,17) @@ -518,7 +518,7 @@ ORDER BY c_first ASC project ├── columns: c_id:1(int!null) c_balance:17(decimal) c_first:4(string) c_middle:5(string) ├── stats: [rows=0.00099] - ├── cost: 0.005346 + ├── cost: 0.035346 ├── key: (1) ├── fd: (1)-->(4,5,17) ├── ordering: +4 @@ -526,7 +526,7 @@ project └── index-join customer ├── columns: c_id:1(int!null) c_d_id:2(int!null) c_w_id:3(int!null) c_first:4(string) c_middle:5(string) c_last:6(string!null) c_balance:17(decimal) ├── stats: [rows=0.00099, distinct(1)=0.00099, null(1)=0, distinct(2)=0.00099, null(2)=0, distinct(3)=0.00099, null(3)=0, distinct(6)=0.00099, null(6)=0] - ├── cost: 0.0053361 + ├── cost: 0.0253361 ├── key: (1) ├── fd: ()-->(2,3,6), (1)-->(4,5,17) ├── ordering: +4 opt(2,3,6) [provided: +4] @@ -535,7 +535,7 @@ project ├── columns: c_id:1(int!null) c_d_id:2(int!null) c_w_id:3(int!null) c_first:4(string) c_last:6(string!null) ├── constraint: /3/2/6/4/1: [/10/100/'Smith' - /10/100/'Smith'] ├── stats: [rows=0.00099, distinct(1)=0.00099, null(1)=0, distinct(2)=0.00099, null(2)=0, distinct(3)=0.00099, null(3)=0, distinct(6)=0.00099, null(6)=0] - ├── cost: 0.001089 + ├── cost: 0.011089 ├── key: (1) ├── fd: ()-->(2,3,6), (1)-->(4) ├── ordering: +4 opt(2,3,6) [provided: +4] @@ -553,7 +553,7 @@ project ├── columns: o_id:1(int!null) o_entry_d:5(timestamp) o_carrier_id:6(int) ├── cardinality: [0 - 1] ├── stats: [rows=0.00099] - ├── cost: 0.0051876 + ├── cost: 0.0351876 ├── key: () ├── fd: ()-->(1,5,6) ├── prune: (1,5,6) @@ -561,7 +561,7 @@ project ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) o_c_id:4(int!null) o_entry_d:5(timestamp) o_carrier_id:6(int) ├── cardinality: [0 - 1] ├── stats: [rows=0.00099] - ├── cost: 0.0051777 + ├── cost: 0.0251777 ├── key: () ├── fd: ()-->(1-6) ├── interesting orderings: (+3,+2,-1) (+3,+2,+4,+1) @@ -570,7 +570,7 @@ project ├── constraint: /3/2/4/1: [/10/100/50 - /10/100/50] ├── limit: 1(rev) ├── stats: [rows=0.00099, distinct(1)=0.00099, null(1)=0, distinct(2)=0.00099, null(2)=0, distinct(3)=0.00099, null(3)=0, distinct(4)=0.00099, null(4)=0] - ├── cost: 0.0010692 + ├── cost: 0.0110692 ├── key: () ├── fd: ()-->(1-4) ├── prune: (1-4) @@ -584,14 +584,14 @@ WHERE ol_w_id = 10 AND ol_d_id = 100 AND ol_o_id = 1000 project ├── columns: ol_i_id:5(int!null) ol_supply_w_id:6(int) ol_quantity:8(int) ol_amount:9(decimal) ol_delivery_d:7(timestamp) ├── stats: [rows=0.001] - ├── cost: 0.00119 + ├── cost: 0.02119 ├── prune: (5-9) ├── interesting orderings: (+6) └── scan order_line ├── columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null) ol_i_id:5(int!null) ol_supply_w_id:6(int) ol_delivery_d:7(timestamp) ol_quantity:8(int) ol_amount:9(decimal) ├── constraint: /3/2/-1/4: [/10/100/1000 - /10/100/1000] ├── stats: [rows=0.001, distinct(1)=0.001, null(1)=0, distinct(2)=0.001, null(2)=0, distinct(3)=0.001, null(3)=0, distinct(5)=0.0009999955, null(5)=0] - ├── cost: 0.00118 + ├── cost: 0.01118 ├── fd: ()-->(1-3) ├── prune: (1-3,5-9) └── interesting orderings: (+3,+2,-1) (+6,+2,+3,+1) @@ -623,7 +623,7 @@ project ├── columns: no_o_id:1(int!null) ├── cardinality: [0 - 1] ├── stats: [rows=0.1] - ├── cost: 0.107 + ├── cost: 0.127 ├── key: () ├── fd: ()-->(1) ├── prune: (1) @@ -632,7 +632,7 @@ project ├── constraint: /3/2/-1: [/10/100 - /10/100] ├── limit: 1(rev) ├── stats: [rows=0.1] - ├── cost: 0.106 + ├── cost: 0.116 ├── key: () ├── fd: ()-->(1-3) ├── prune: (1-3) @@ -647,7 +647,7 @@ scalar-group-by ├── columns: sum:11(decimal) ├── cardinality: [1 - 1] ├── stats: [rows=1] - ├── cost: 0.01115 + ├── cost: 0.03115 ├── key: () ├── fd: ()-->(11) ├── prune: (11) @@ -655,7 +655,7 @@ scalar-group-by │ ├── columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null) ol_amount:9(decimal) │ ├── constraint: /3/2/-1/4: [/10/100/1000 - /10/100/1000] │ ├── stats: [rows=0.001, distinct(1)=0.001, null(1)=0, distinct(2)=0.001, null(2)=0, distinct(3)=0.001, null(3)=0] - │ ├── cost: 0.00114 + │ ├── cost: 0.01114 │ ├── fd: ()-->(1-3) │ ├── prune: (1-3,9) │ └── interesting orderings: (+3,+2,-1) @@ -680,7 +680,7 @@ project ├── columns: d_next_o_id:11(int) ├── cardinality: [0 - 1] ├── stats: [rows=0.1] - ├── cost: 0.115 + ├── cost: 0.135 ├── key: () ├── fd: ()-->(11) ├── prune: (11) @@ -689,7 +689,7 @@ project ├── constraint: /2/1: [/10/100 - /10/100] ├── cardinality: [0 - 1] ├── stats: [rows=0.1, distinct(1)=0.1, null(1)=0, distinct(2)=0.1, null(2)=0] - ├── cost: 0.114 + ├── cost: 0.124 ├── key: () ├── fd: ()-->(1,2,11) ├── prune: (1,2,11) @@ -709,7 +709,7 @@ scalar-group-by ├── columns: count:28(int) ├── cardinality: [1 - 1] ├── stats: [rows=1] - ├── cost: 0.111477778 + ├── cost: 0.141477778 ├── key: () ├── fd: ()-->(28) ├── prune: (28) @@ -717,14 +717,14 @@ scalar-group-by │ ├── columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null) ol_i_id:5(int!null) s_i_id:11(int!null) s_w_id:12(int!null) s_quantity:13(int!null) │ ├── key columns: [3 5] = [12 11] │ ├── stats: [rows=0.0366666667, distinct(1)=0.0111105556, null(1)=0, distinct(2)=0.0111111111, null(2)=0, distinct(3)=0.0111111111, null(3)=0, distinct(5)=0.0111105556, null(5)=0, distinct(11)=0.0111105556, null(11)=0, distinct(12)=0.0111111111, null(12)=0, distinct(13)=0.0366666667, null(13)=0] - │ ├── cost: 0.101111111 + │ ├── cost: 0.121111111 │ ├── fd: ()-->(2,3,12), (11)-->(13), (5)==(11), (11)==(5), (3)==(12), (12)==(3) │ ├── interesting orderings: (+3,+2,-1) │ ├── scan order_line │ │ ├── columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null) ol_i_id:5(int!null) │ │ ├── constraint: /3/2/-1/4: [/10/100/999 - /10/100/980] │ │ ├── stats: [rows=0.0111111111, distinct(1)=0.0111105556, null(1)=0, distinct(2)=0.0111111111, null(2)=0, distinct(3)=0.0111111111, null(3)=0, distinct(5)=0.0111105556, null(5)=0] - │ │ ├── cost: 0.0126666667 + │ │ ├── cost: 0.0226666667 │ │ ├── fd: ()-->(2,3) │ │ ├── prune: (5) │ │ └── interesting orderings: (+3,+2,-1) @@ -762,7 +762,7 @@ scalar-group-by ├── columns: count:22(int) ├── cardinality: [1 - 1] ├── stats: [rows=1] - ├── cost: 1587.97 + ├── cost: 1588.01 ├── key: () ├── fd: ()-->(22) ├── prune: (22) @@ -770,7 +770,7 @@ scalar-group-by │ ├── columns: w_id:1(int!null) w_ytd:9(decimal!null) d_w_id:11(int!null) sum:21(decimal!null) │ ├── key columns: [11] = [1] │ ├── stats: [rows=33, distinct(1)=33, null(1)=0, distinct(9)=28.3508504, null(9)=0, distinct(11)=33, null(11)=0, distinct(21)=28.3508504, null(21)=0] - │ ├── cost: 1587.63 + │ ├── cost: 1587.66 │ ├── key: (11) │ ├── fd: (1)-->(9), (11)-->(21), (1)==(11), (11)==(1) │ ├── interesting orderings: (+11) @@ -779,7 +779,7 @@ scalar-group-by │ │ ├── grouping columns: d_w_id:11(int!null) │ │ ├── internal-ordering: +11 │ │ ├── stats: [rows=100, distinct(11)=100, null(11)=0, distinct(21)=100, null(21)=0] - │ │ ├── cost: 1151 + │ │ ├── cost: 1151.02 │ │ ├── key: (11) │ │ ├── fd: (11)-->(21) │ │ ├── prune: (21) @@ -787,7 +787,7 @@ scalar-group-by │ │ ├── scan district │ │ │ ├── columns: d_w_id:11(int!null) d_ytd:19(decimal) │ │ │ ├── stats: [rows=1000, distinct(11)=100, null(11)=0] - │ │ │ ├── cost: 1130 + │ │ │ ├── cost: 1130.01 │ │ │ ├── ordering: +11 │ │ │ ├── prune: (11,19) │ │ │ └── interesting orderings: (+11) @@ -809,7 +809,7 @@ ORDER BY d_w_id, d_id scan district ├── columns: d_next_o_id:11(int) [hidden: d_id:1(int!null) d_w_id:2(int!null)] ├── stats: [rows=1000] - ├── cost: 1140 + ├── cost: 1140.01 ├── key: (1,2) ├── fd: (1,2)-->(11) ├── ordering: +2,+1 @@ -826,7 +826,7 @@ group-by ├── columns: max:4(int) [hidden: no_d_id:2(int!null) no_w_id:3(int!null)] ├── grouping columns: no_d_id:2(int!null) no_w_id:3(int!null) ├── stats: [rows=1000, distinct(2,3)=1000, null(2,3)=0] - ├── cost: 1100 + ├── cost: 1100.02 ├── key: (2,3) ├── fd: (2,3)-->(4) ├── ordering: +3,+2 @@ -835,7 +835,7 @@ group-by ├── scan new_order │ ├── columns: no_o_id:1(int!null) no_d_id:2(int!null) no_w_id:3(int!null) │ ├── stats: [rows=1000, distinct(2,3)=1000, null(2,3)=0] - │ ├── cost: 1060 + │ ├── cost: 1060.01 │ ├── key: (1-3) │ ├── ordering: +3,+2 │ ├── prune: (1-3) @@ -854,7 +854,7 @@ group-by ├── columns: max:9(int) [hidden: o_d_id:2(int!null) o_w_id:3(int!null)] ├── grouping columns: o_d_id:2(int!null) o_w_id:3(int!null) ├── stats: [rows=1000, distinct(2,3)=1000, null(2,3)=0] - ├── cost: 1110 + ├── cost: 1110.02 ├── key: (2,3) ├── fd: (2,3)-->(9) ├── ordering: +3,+2 @@ -863,7 +863,7 @@ group-by ├── scan order@order_idx │ ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) │ ├── stats: [rows=1000, distinct(2,3)=1000, null(2,3)=0] - │ ├── cost: 1070 + │ ├── cost: 1070.01 │ ├── key: (1-3) │ ├── ordering: +3,+2 │ ├── prune: (1-3) @@ -886,14 +886,14 @@ scalar-group-by ├── columns: count:8(int) ├── cardinality: [1 - 1] ├── stats: [rows=1] - ├── cost: 1133.34333 + ├── cost: 1133.38333 ├── key: () ├── fd: ()-->(8) ├── prune: (8) ├── select │ ├── columns: no_d_id:2(int!null) no_w_id:3(int!null) max:4(int) min:5(int) count_rows:6(int) │ ├── stats: [rows=333.333333, distinct(2)=98.265847, null(2)=0, distinct(3)=98.265847, null(3)=0] - │ ├── cost: 1130 + │ ├── cost: 1130.03 │ ├── key: (2,3) │ ├── fd: (2,3)-->(4-6) │ ├── interesting orderings: (+3,+2) @@ -902,7 +902,7 @@ scalar-group-by │ │ ├── grouping columns: no_d_id:2(int!null) no_w_id:3(int!null) │ │ ├── internal-ordering: +3,+2 │ │ ├── stats: [rows=1000, distinct(2)=100, null(2)=0, distinct(3)=100, null(3)=0, distinct(2,3)=1000, null(2,3)=0] - │ │ ├── cost: 1120 + │ │ ├── cost: 1120.02 │ │ ├── key: (2,3) │ │ ├── fd: (2,3)-->(4-6) │ │ ├── prune: (4-6) @@ -910,7 +910,7 @@ scalar-group-by │ │ ├── scan new_order │ │ │ ├── columns: no_o_id:1(int!null) no_d_id:2(int!null) no_w_id:3(int!null) │ │ │ ├── stats: [rows=1000, distinct(2)=100, null(2)=0, distinct(3)=100, null(3)=0, distinct(2,3)=1000, null(2,3)=0] - │ │ │ ├── cost: 1060 + │ │ │ ├── cost: 1060.01 │ │ │ ├── key: (1-3) │ │ │ ├── ordering: +3,+2 │ │ │ ├── prune: (1-3) @@ -942,7 +942,7 @@ group-by ├── columns: sum:9(decimal) [hidden: o_d_id:2(int!null) o_w_id:3(int!null)] ├── grouping columns: o_d_id:2(int!null) o_w_id:3(int!null) ├── stats: [rows=1000, distinct(2,3)=1000, null(2,3)=0] - ├── cost: 1150 + ├── cost: 1150.02 ├── key: (2,3) ├── fd: (2,3)-->(9) ├── ordering: +3,+2 @@ -951,7 +951,7 @@ group-by ├── scan order │ ├── columns: o_d_id:2(int!null) o_w_id:3(int!null) o_ol_cnt:7(int) │ ├── stats: [rows=1000, distinct(2,3)=1000, null(2,3)=0] - │ ├── cost: 1110 + │ ├── cost: 1110.01 │ ├── ordering: +3,+2 │ ├── prune: (2,3,7) │ └── interesting orderings: (+3,+2) @@ -969,7 +969,7 @@ group-by ├── columns: count:11(int) [hidden: ol_d_id:2(int!null) ol_w_id:3(int!null)] ├── grouping columns: ol_d_id:2(int!null) ol_w_id:3(int!null) ├── stats: [rows=1000, distinct(2,3)=1000, null(2,3)=0] - ├── cost: 1160 + ├── cost: 1160.02 ├── key: (2,3) ├── fd: (2,3)-->(11) ├── ordering: +3,+2 @@ -978,7 +978,7 @@ group-by ├── scan order_line │ ├── columns: ol_d_id:2(int!null) ol_w_id:3(int!null) │ ├── stats: [rows=1000, distinct(2,3)=1000, null(2,3)=0] - │ ├── cost: 1120 + │ ├── cost: 1120.01 │ ├── ordering: +3,+2 │ ├── prune: (2,3) │ └── interesting orderings: (+3,+2) @@ -995,25 +995,25 @@ except-all ├── left columns: no_w_id:3(int!null) no_d_id:2(int!null) no_o_id:1(int!null) ├── right columns: o_w_id:6(int) o_d_id:5(int) o_id:4(int) ├── stats: [rows=1000] - ├── cost: 2170.2 + ├── cost: 2170.25 ├── scan new_order │ ├── columns: no_o_id:1(int!null) no_d_id:2(int!null) no_w_id:3(int!null) │ ├── stats: [rows=1000] - │ ├── cost: 1060 + │ ├── cost: 1060.01 │ ├── key: (1-3) │ ├── prune: (1-3) │ └── interesting orderings: (+3,+2,-1) └── project ├── columns: o_id:4(int!null) o_d_id:5(int!null) o_w_id:6(int!null) ├── stats: [rows=10] - ├── cost: 1090.1 + ├── cost: 1090.13 ├── key: (4-6) ├── prune: (4-6) ├── interesting orderings: (+6,+5,-4) └── select ├── columns: o_id:4(int!null) o_d_id:5(int!null) o_w_id:6(int!null) o_carrier_id:9(int) ├── stats: [rows=10, distinct(4)=9.5617925, null(4)=0, distinct(5)=9.5617925, null(5)=0, distinct(6)=9.5617925, null(6)=0, distinct(9)=1, null(9)=10] - ├── cost: 1090 + ├── cost: 1090.02 ├── key: (4-6) ├── fd: ()-->(9) ├── prune: (4-6) @@ -1021,7 +1021,7 @@ except-all ├── scan order@order_idx │ ├── columns: o_id:4(int!null) o_d_id:5(int!null) o_w_id:6(int!null) o_carrier_id:9(int) │ ├── stats: [rows=1000, distinct(4)=100, null(4)=0, distinct(5)=100, null(5)=0, distinct(6)=100, null(6)=0, distinct(9)=100, null(9)=10] - │ ├── cost: 1080 + │ ├── cost: 1080.01 │ ├── key: (4-6) │ ├── fd: (4-6)-->(9) │ ├── prune: (4-6,9) @@ -1041,18 +1041,18 @@ except-all ├── left columns: o_w_id:3(int!null) o_d_id:2(int!null) o_id:1(int!null) ├── right columns: no_w_id:11(int) no_d_id:10(int) no_o_id:9(int) ├── stats: [rows=10] - ├── cost: 2160.3 + ├── cost: 2160.35 ├── project │ ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) │ ├── stats: [rows=10] - │ ├── cost: 1090.1 + │ ├── cost: 1090.13 │ ├── key: (1-3) │ ├── prune: (1-3) │ ├── interesting orderings: (+3,+2,-1) │ └── select │ ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) o_carrier_id:6(int) │ ├── stats: [rows=10, distinct(1)=9.5617925, null(1)=0, distinct(2)=9.5617925, null(2)=0, distinct(3)=9.5617925, null(3)=0, distinct(6)=1, null(6)=10] - │ ├── cost: 1090 + │ ├── cost: 1090.02 │ ├── key: (1-3) │ ├── fd: ()-->(6) │ ├── prune: (1-3) @@ -1060,7 +1060,7 @@ except-all │ ├── scan order@order_idx │ │ ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) o_carrier_id:6(int) │ │ ├── stats: [rows=1000, distinct(1)=100, null(1)=0, distinct(2)=100, null(2)=0, distinct(3)=100, null(3)=0, distinct(6)=100, null(6)=10] - │ │ ├── cost: 1080 + │ │ ├── cost: 1080.01 │ │ ├── key: (1-3) │ │ ├── fd: (1-3)-->(6) │ │ ├── prune: (1-3,6) @@ -1072,7 +1072,7 @@ except-all └── scan new_order ├── columns: no_o_id:9(int!null) no_d_id:10(int!null) no_w_id:11(int!null) ├── stats: [rows=1000] - ├── cost: 1060 + ├── cost: 1060.01 ├── key: (9-11) ├── prune: (9-11) └── interesting orderings: (+11,+10,-9) @@ -1096,11 +1096,11 @@ except-all ├── left columns: o_w_id:3(int!null) o_d_id:2(int!null) o_id:1(int!null) o_ol_cnt:7(int) ├── right columns: ol_w_id:11(int) ol_d_id:10(int) ol_o_id:9(int) count_rows:19(int) ├── stats: [rows=1000] - ├── cost: 2290 + ├── cost: 2290.04 ├── scan order │ ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) o_ol_cnt:7(int) │ ├── stats: [rows=1000] - │ ├── cost: 1120 + │ ├── cost: 1120.01 │ ├── key: (1-3) │ ├── fd: (1-3)-->(7) │ ├── prune: (1-3,7) @@ -1109,7 +1109,7 @@ except-all ├── columns: ol_o_id:9(int!null) ol_d_id:10(int!null) ol_w_id:11(int!null) count_rows:19(int) ├── grouping columns: ol_o_id:9(int!null) ol_d_id:10(int!null) ol_w_id:11(int!null) ├── stats: [rows=1000, distinct(9-11)=1000, null(9-11)=0] - ├── cost: 1140 + ├── cost: 1140.02 ├── key: (9-11) ├── fd: (9-11)-->(19) ├── prune: (19) @@ -1117,7 +1117,7 @@ except-all ├── scan order_line@order_line_fk │ ├── columns: ol_o_id:9(int!null) ol_d_id:10(int!null) ol_w_id:11(int!null) │ ├── stats: [rows=1000, distinct(9-11)=1000, null(9-11)=0] - │ ├── cost: 1080 + │ ├── cost: 1080.01 │ ├── prune: (9-11) │ └── interesting orderings: (+11,+10,-9) └── aggregations @@ -1142,12 +1142,12 @@ except-all ├── left columns: ol_w_id:3(int!null) ol_d_id:2(int!null) ol_o_id:1(int!null) count_rows:11(int) ├── right columns: o_w_id:14(int) o_d_id:13(int) o_id:12(int) o_ol_cnt:18(int) ├── stats: [rows=1000] - ├── cost: 2290 + ├── cost: 2290.04 ├── group-by │ ├── columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null) count_rows:11(int) │ ├── grouping columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null) │ ├── stats: [rows=1000, distinct(1-3)=1000, null(1-3)=0] - │ ├── cost: 1140 + │ ├── cost: 1140.02 │ ├── key: (1-3) │ ├── fd: (1-3)-->(11) │ ├── prune: (11) @@ -1155,7 +1155,7 @@ except-all │ ├── scan order_line@order_line_fk │ │ ├── columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null) │ │ ├── stats: [rows=1000, distinct(1-3)=1000, null(1-3)=0] - │ │ ├── cost: 1080 + │ │ ├── cost: 1080.01 │ │ ├── prune: (1-3) │ │ └── interesting orderings: (+3,+2,-1) │ └── aggregations @@ -1163,7 +1163,7 @@ except-all └── scan order ├── columns: o_id:12(int!null) o_d_id:13(int!null) o_w_id:14(int!null) o_ol_cnt:18(int) ├── stats: [rows=1000] - ├── cost: 1120 + ├── cost: 1120.01 ├── key: (12-14) ├── fd: (12-14)-->(18) ├── prune: (12-14,18) @@ -1190,32 +1190,32 @@ scalar-group-by ├── columns: count:19(int) ├── cardinality: [1 - 1] ├── stats: [rows=1] - ├── cost: 2240.974 + ├── cost: 2241.064 ├── key: () ├── fd: ()-->(19) ├── prune: (19) ├── select │ ├── columns: o_id:1(int) o_d_id:2(int) o_w_id:3(int) ol_o_id:9(int) ol_d_id:10(int) ol_w_id:11(int) │ ├── stats: [rows=6.62853719] - │ ├── cost: 2240.89771 + │ ├── cost: 2240.97771 │ ├── interesting orderings: (+3,+2,-1) (+11,+10,-9) │ ├── full-join │ │ ├── columns: o_id:1(int) o_d_id:2(int) o_w_id:3(int) ol_o_id:9(int) ol_d_id:10(int) ol_w_id:11(int) │ │ ├── stats: [rows=19.8856116] - │ │ ├── cost: 2240.69886 + │ │ ├── cost: 2240.76886 │ │ ├── reject-nulls: (1-3,9-11) │ │ ├── interesting orderings: (+3,+2,-1) (+11,+10,-9) │ │ ├── project │ │ │ ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) │ │ │ ├── stats: [rows=10, distinct(1)=9.5617925, null(1)=0, distinct(2)=9.5617925, null(2)=0, distinct(3)=9.5617925, null(3)=0] - │ │ │ ├── cost: 1090.1 + │ │ │ ├── cost: 1090.13 │ │ │ ├── key: (1-3) │ │ │ ├── prune: (1-3) │ │ │ ├── interesting orderings: (+3,+2,-1) │ │ │ └── select │ │ │ ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) o_carrier_id:6(int) │ │ │ ├── stats: [rows=10, distinct(1)=9.5617925, null(1)=0, distinct(2)=9.5617925, null(2)=0, distinct(3)=9.5617925, null(3)=0, distinct(6)=1, null(6)=10] - │ │ │ ├── cost: 1090 + │ │ │ ├── cost: 1090.02 │ │ │ ├── key: (1-3) │ │ │ ├── fd: ()-->(6) │ │ │ ├── prune: (1-3) @@ -1223,7 +1223,7 @@ scalar-group-by │ │ │ ├── scan order@order_idx │ │ │ │ ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) o_carrier_id:6(int) │ │ │ │ ├── stats: [rows=1000, distinct(1)=100, null(1)=0, distinct(2)=100, null(2)=0, distinct(3)=100, null(3)=0, distinct(6)=100, null(6)=10] - │ │ │ │ ├── cost: 1080 + │ │ │ │ ├── cost: 1080.01 │ │ │ │ ├── key: (1-3) │ │ │ │ ├── fd: (1-3)-->(6) │ │ │ │ ├── prune: (1-3,6) @@ -1235,20 +1235,20 @@ scalar-group-by │ │ ├── project │ │ │ ├── columns: ol_o_id:9(int!null) ol_d_id:10(int!null) ol_w_id:11(int!null) │ │ │ ├── stats: [rows=10, distinct(9)=9.5617925, null(9)=0, distinct(10)=9.5617925, null(10)=0, distinct(11)=9.5617925, null(11)=0] - │ │ │ ├── cost: 1150.1 + │ │ │ ├── cost: 1150.13 │ │ │ ├── prune: (9-11) │ │ │ ├── interesting orderings: (+11,+10,-9) │ │ │ └── select │ │ │ ├── columns: ol_o_id:9(int!null) ol_d_id:10(int!null) ol_w_id:11(int!null) ol_delivery_d:15(timestamp) │ │ │ ├── stats: [rows=10, distinct(9)=9.5617925, null(9)=0, distinct(10)=9.5617925, null(10)=0, distinct(11)=9.5617925, null(11)=0, distinct(15)=1, null(15)=10] - │ │ │ ├── cost: 1150 + │ │ │ ├── cost: 1150.02 │ │ │ ├── fd: ()-->(15) │ │ │ ├── prune: (9-11) │ │ │ ├── interesting orderings: (+11,+10,-9) │ │ │ ├── scan order_line │ │ │ │ ├── columns: ol_o_id:9(int!null) ol_d_id:10(int!null) ol_w_id:11(int!null) ol_delivery_d:15(timestamp) │ │ │ │ ├── stats: [rows=1000, distinct(9)=100, null(9)=0, distinct(10)=100, null(10)=0, distinct(11)=100, null(11)=0, distinct(15)=100, null(15)=10] - │ │ │ │ ├── cost: 1140 + │ │ │ │ ├── cost: 1140.01 │ │ │ │ ├── prune: (9-11,15) │ │ │ │ └── interesting orderings: (+11,+10,-9) │ │ │ └── filters diff --git a/pkg/sql/opt/xform/testdata/physprops/ordering b/pkg/sql/opt/xform/testdata/physprops/ordering index b8119c5bad0d..a86a28729ac9 100644 --- a/pkg/sql/opt/xform/testdata/physprops/ordering +++ b/pkg/sql/opt/xform/testdata/physprops/ordering @@ -218,25 +218,25 @@ memo (optimized, ~5KB, required=[presentation: y:2,z:5] [ordering: +1,-2]) ├── G1: (project G2 G3 x y) │ ├── [presentation: y:2,z:5] [ordering: +1,-2] │ │ ├── best: (project G2="[ordering: +1,-2]" G3 x y) - │ │ └── cost: 1076.67 + │ │ └── cost: 1076.70 │ └── [] │ ├── best: (project G2 G3 x y) - │ └── cost: 1076.67 + │ └── cost: 1076.70 ├── G2: (select G4 G5) │ ├── [ordering: +1,-2] │ │ ├── best: (select G4="[ordering: +1,-2]" G5) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.02 │ └── [] │ ├── best: (select G4 G5) - │ └── cost: 1070.00 + │ └── cost: 1070.02 ├── G3: (projections G6) ├── G4: (scan a,cols=(1,2)) │ ├── [ordering: +1,-2] │ │ ├── best: (scan a,cols=(1,2)) - │ │ └── cost: 1060.00 + │ │ └── cost: 1060.01 │ └── [] │ ├── best: (scan a,cols=(1,2)) - │ └── cost: 1060.00 + │ └── cost: 1060.01 ├── G5: (filters G7) ├── G6: (minus G8 G9) ├── G7: (gt G8 G10) @@ -267,25 +267,25 @@ memo (optimized, ~4KB, required=[presentation: y:2,z:3] [ordering: +2]) ├── G1: (project G2 G3 y z) │ ├── [presentation: y:2,z:3] [ordering: +2] │ │ ├── best: (sort G1) - │ │ └── cost: 1145.87 + │ │ └── cost: 1145.91 │ └── [] │ ├── best: (project G2 G3 y z) - │ └── cost: 1083.33 + │ └── cost: 1083.36 ├── G2: (select G4 G5) │ ├── [ordering: +2] │ │ ├── best: (sort G2) - │ │ └── cost: 1142.54 + │ │ └── cost: 1142.57 │ └── [] │ ├── best: (select G4 G5) - │ └── cost: 1080.00 + │ └── cost: 1080.02 ├── G3: (projections) ├── G4: (scan a,cols=(1-3)) │ ├── [ordering: +2] │ │ ├── best: (sort G4) - │ │ └── cost: 1289.32 + │ │ └── cost: 1289.34 │ └── [] │ ├── best: (scan a,cols=(1-3)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G5: (filters G6) ├── G6: (gt G7 G8) ├── G7: (variable x) @@ -534,14 +534,14 @@ memo (optimized, ~1KB, required=[presentation: tree:5,field:8,description:9,colu ├── G1: (explain G2 [presentation: x:1,y:2,z:3,s:4] [ordering: +2]) │ └── [presentation: tree:5,field:8,description:9,columns:10,ordering:11] │ ├── best: (explain G2="[presentation: x:1,y:2,z:3,s:4] [ordering: +2]" [presentation: x:1,y:2,z:3,s:4] [ordering: +2]) - │ └── cost: 1299.32 + │ └── cost: 1299.35 └── G2: (scan a) ├── [presentation: x:1,y:2,z:3,s:4] [ordering: +2] │ ├── best: (sort G2) - │ └── cost: 1299.32 + │ └── cost: 1299.34 └── [] ├── best: (scan a) - └── cost: 1080.00 + └── cost: 1080.01 # -------------------------------------------------- # With Ordinality @@ -554,14 +554,14 @@ memo (optimized, ~3KB, required=[presentation: y:2] [ordering: +5]) ├── G1: (row-number G2) │ ├── [presentation: y:2] [ordering: +5] │ │ ├── best: (row-number G2) - │ │ └── cost: 1060.00 + │ │ └── cost: 1060.02 │ └── [] │ ├── best: (row-number G2) - │ └── cost: 1060.00 + │ └── cost: 1060.02 └── G2: (scan a,cols=(2)) └── [] ├── best: (scan a,cols=(2)) - └── cost: 1050.00 + └── cost: 1050.01 memo SELECT y FROM a WITH ORDINALITY ORDER BY -ordinality @@ -570,19 +570,19 @@ memo (optimized, ~4KB, required=[presentation: y:2] [ordering: +6]) ├── G1: (project G2 G3 y) │ ├── [presentation: y:2] [ordering: +6] │ │ ├── best: (sort G1) - │ │ └── cost: 1299.32 + │ │ └── cost: 1299.36 │ └── [] │ ├── best: (project G2 G3 y) - │ └── cost: 1080.00 + │ └── cost: 1080.03 ├── G2: (row-number G4) │ └── [] │ ├── best: (row-number G4) - │ └── cost: 1060.00 + │ └── cost: 1060.02 ├── G3: (projections G5) ├── G4: (scan a,cols=(2)) │ └── [] │ ├── best: (scan a,cols=(2)) - │ └── cost: 1050.00 + │ └── cost: 1050.01 ├── G5: (unary-minus G6) └── G6: (variable ordinality) @@ -593,14 +593,14 @@ memo (optimized, ~5KB, required=[presentation: y:2] [ordering: +5]) ├── G1: (row-number G2) │ ├── [presentation: y:2] [ordering: +5] │ │ ├── best: (row-number G2) - │ │ └── cost: 1060.00 + │ │ └── cost: 1060.02 │ └── [] │ ├── best: (row-number G2) - │ └── cost: 1060.00 + │ └── cost: 1060.02 └── G2: (scan a,cols=(2)) └── [] ├── best: (scan a,cols=(2)) - └── cost: 1050.00 + └── cost: 1050.01 memo SELECT y FROM (SELECT * FROM a ORDER BY y) WITH ORDINALITY ORDER BY y, ordinality @@ -609,17 +609,17 @@ memo (optimized, ~3KB, required=[presentation: y:2] [ordering: +2,+5]) ├── G1: (row-number G2 ordering=+2) │ ├── [presentation: y:2] [ordering: +2,+5] │ │ ├── best: (row-number G2="[ordering: +2]" ordering=+2) - │ │ └── cost: 1279.32 + │ │ └── cost: 1279.35 │ └── [] │ ├── best: (row-number G2="[ordering: +2]" ordering=+2) - │ └── cost: 1279.32 + │ └── cost: 1279.35 └── G2: (scan a,cols=(2)) ├── [ordering: +2] │ ├── best: (sort G2) - │ └── cost: 1269.32 + │ └── cost: 1269.34 └── [] ├── best: (scan a,cols=(2)) - └── cost: 1050.00 + └── cost: 1050.01 memo SELECT y FROM (SELECT * FROM a ORDER BY y) WITH ORDINALITY ORDER BY ordinality, y @@ -628,17 +628,17 @@ memo (optimized, ~3KB, required=[presentation: y:2] [ordering: +5]) ├── G1: (row-number G2 ordering=+2) │ ├── [presentation: y:2] [ordering: +5] │ │ ├── best: (row-number G2="[ordering: +2]" ordering=+2) - │ │ └── cost: 1279.32 + │ │ └── cost: 1279.35 │ └── [] │ ├── best: (row-number G2="[ordering: +2]" ordering=+2) - │ └── cost: 1279.32 + │ └── cost: 1279.35 └── G2: (scan a,cols=(2)) ├── [ordering: +2] │ ├── best: (sort G2) - │ └── cost: 1269.32 + │ └── cost: 1269.34 └── [] ├── best: (scan a,cols=(2)) - └── cost: 1050.00 + └── cost: 1050.01 memo SELECT y FROM a WITH ORDINALITY ORDER BY ordinality DESC @@ -647,14 +647,14 @@ memo (optimized, ~3KB, required=[presentation: y:2] [ordering: -5]) ├── G1: (row-number G2) │ ├── [presentation: y:2] [ordering: -5] │ │ ├── best: (sort G1) - │ │ └── cost: 1279.32 + │ │ └── cost: 1279.35 │ └── [] │ ├── best: (row-number G2) - │ └── cost: 1060.00 + │ └── cost: 1060.02 └── G2: (scan a,cols=(2)) └── [] ├── best: (scan a,cols=(2)) - └── cost: 1050.00 + └── cost: 1050.01 # -------------------------------------------------- # Merge Join diff --git a/pkg/sql/opt/xform/testdata/rules/groupby b/pkg/sql/opt/xform/testdata/rules/groupby index f417f29c5c09..88d16f462c27 100644 --- a/pkg/sql/opt/xform/testdata/rules/groupby +++ b/pkg/sql/opt/xform/testdata/rules/groupby @@ -517,19 +517,19 @@ memo (optimized, ~4KB, required=[presentation: min:5]) ├── G1: (scalar-group-by G2 G3 cols=()) (scalar-group-by G4 G5 cols=()) │ └── [presentation: min:5] │ ├── best: (scalar-group-by G4 G5 cols=()) - │ └── cost: 1.07 + │ └── cost: 1.09 ├── G2: (scan abc,cols=(1)) │ ├── [ordering: +1] │ │ ├── best: (scan abc,cols=(1)) - │ │ └── cost: 1050.00 + │ │ └── cost: 1050.01 │ └── [] │ ├── best: (scan abc,cols=(1)) - │ └── cost: 1050.00 + │ └── cost: 1050.01 ├── G3: (aggregations G6) ├── G4: (limit G2 G7 ordering=+1) (scan abc,cols=(1),lim=1) │ └── [] │ ├── best: (scan abc,cols=(1),lim=1) - │ └── cost: 1.05 + │ └── cost: 1.06 ├── G5: (aggregations G8) ├── G6: (min G9) ├── G7: (const 1) @@ -543,28 +543,28 @@ memo (optimized, ~5KB, required=[presentation: min:5]) ├── G1: (scalar-group-by G2 G3 cols=()) (scalar-group-by G4 G5 cols=()) │ └── [presentation: min:5] │ ├── best: (scalar-group-by G2 G3 cols=()) - │ └── cost: 1060.01 + │ └── cost: 1060.03 ├── G2: (scan abc,cols=(2)) │ ├── [ordering: +2] │ │ ├── best: (sort G2) - │ │ └── cost: 1269.32 + │ │ └── cost: 1269.34 │ └── [] │ ├── best: (scan abc,cols=(2)) - │ └── cost: 1050.00 + │ └── cost: 1050.01 ├── G3: (aggregations G6) ├── G4: (limit G7 G8 ordering=+2) │ └── [] │ ├── best: (limit G7="[ordering: +2]" G8 ordering=+2) - │ └── cost: 1276.85 + │ └── cost: 1276.89 ├── G5: (aggregations G9) ├── G6: (min G10) ├── G7: (select G2 G11) │ ├── [ordering: +2] │ │ ├── best: (sort G7) - │ │ └── cost: 1276.84 + │ │ └── cost: 1276.87 │ └── [] │ ├── best: (select G2 G11) - │ └── cost: 1060.00 + │ └── cost: 1060.02 ├── G8: (const 1) ├── G9: (const-agg G10) ├── G10: (variable b) @@ -579,19 +579,19 @@ memo (optimized, ~4KB, required=[presentation: max:5]) ├── G1: (scalar-group-by G2 G3 cols=()) (scalar-group-by G4 G5 cols=()) │ └── [presentation: max:5] │ ├── best: (scalar-group-by G4 G5 cols=()) - │ └── cost: 1.07 + │ └── cost: 1.09 ├── G2: (scan abc,cols=(1)) │ ├── [ordering: -1] │ │ ├── best: (scan abc,rev,cols=(1)) - │ │ └── cost: 1149.66 + │ │ └── cost: 1149.67 │ └── [] │ ├── best: (scan abc,cols=(1)) - │ └── cost: 1050.00 + │ └── cost: 1050.01 ├── G3: (aggregations G6) ├── G4: (limit G2 G7 ordering=-1) (scan abc,rev,cols=(1),lim=1(rev)) │ └── [] │ ├── best: (scan abc,rev,cols=(1),lim=1(rev)) - │ └── cost: 1.05 + │ └── cost: 1.06 ├── G5: (aggregations G8) ├── G6: (max G9) ├── G7: (const 1) @@ -605,28 +605,28 @@ memo (optimized, ~5KB, required=[presentation: max:5]) ├── G1: (scalar-group-by G2 G3 cols=()) (scalar-group-by G4 G5 cols=()) │ └── [presentation: max:5] │ ├── best: (scalar-group-by G2 G3 cols=()) - │ └── cost: 1060.01 + │ └── cost: 1060.03 ├── G2: (scan abc,cols=(2)) │ ├── [ordering: -2] │ │ ├── best: (sort G2) - │ │ └── cost: 1269.32 + │ │ └── cost: 1269.34 │ └── [] │ ├── best: (scan abc,cols=(2)) - │ └── cost: 1050.00 + │ └── cost: 1050.01 ├── G3: (aggregations G6) ├── G4: (limit G7 G8 ordering=-2) │ └── [] │ ├── best: (limit G7="[ordering: -2]" G8 ordering=-2) - │ └── cost: 1276.85 + │ └── cost: 1276.89 ├── G5: (aggregations G9) ├── G6: (max G10) ├── G7: (select G2 G11) │ ├── [ordering: -2] │ │ ├── best: (sort G7) - │ │ └── cost: 1276.84 + │ │ └── cost: 1276.87 │ └── [] │ ├── best: (select G2 G11) - │ └── cost: 1060.00 + │ └── cost: 1060.02 ├── G8: (const 1) ├── G9: (const-agg G10) ├── G10: (variable b) @@ -694,28 +694,28 @@ memo (optimized, ~5KB, required=[presentation: max:5]) ├── G1: (scalar-group-by G2 G3 cols=()) (scalar-group-by G4 G5 cols=()) │ └── [presentation: max:5] │ ├── best: (scalar-group-by G2 G3 cols=()) - │ └── cost: 1060.01 + │ └── cost: 1060.03 ├── G2: (scan abc,cols=(2)) │ ├── [ordering: -2] │ │ ├── best: (sort G2) - │ │ └── cost: 1269.32 + │ │ └── cost: 1269.34 │ └── [] │ ├── best: (scan abc,cols=(2)) - │ └── cost: 1050.00 + │ └── cost: 1050.01 ├── G3: (aggregations G6) ├── G4: (limit G7 G8 ordering=-2) │ └── [] │ ├── best: (limit G7="[ordering: -2]" G8 ordering=-2) - │ └── cost: 1276.85 + │ └── cost: 1276.89 ├── G5: (aggregations G9) ├── G6: (max G10) ├── G7: (select G2 G11) │ ├── [ordering: -2] │ │ ├── best: (sort G7) - │ │ └── cost: 1276.84 + │ │ └── cost: 1276.87 │ └── [] │ ├── best: (select G2 G11) - │ └── cost: 1060.00 + │ └── cost: 1060.02 ├── G8: (const 1) ├── G9: (const-agg G10) ├── G10: (variable b) @@ -735,28 +735,28 @@ memo (optimized, ~5KB, required=[presentation: array_agg:5]) ├── G1: (project G2 G3 array_agg) │ └── [presentation: array_agg:5] │ ├── best: (project G2 G3 array_agg) - │ └── cost: 1120.00 + │ └── cost: 1120.03 ├── G2: (group-by G4 G5 cols=(2,3),ordering=+4 opt(2,3)) (group-by G4 G5 cols=(2,3),ordering=+2,+3,+4) (group-by G4 G5 cols=(2,3),ordering=+4,+3,+2) (group-by G4 G5 cols=(2,3),ordering=+3,+4) │ └── [] │ ├── best: (group-by G4="[ordering: +2,+3,+4]" G5 cols=(2,3),ordering=+2,+3,+4) - │ └── cost: 1110.00 + │ └── cost: 1110.02 ├── G3: (projections) ├── G4: (scan kuvw,cols=(2-4)) (scan kuvw@uvw,cols=(2-4)) (scan kuvw@wvu,cols=(2-4)) (scan kuvw@vw,cols=(2-4)) (scan kuvw@w,cols=(2-4)) │ ├── [ordering: +2,+3,+4] │ │ ├── best: (scan kuvw@uvw,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ ├── [ordering: +3,+4] │ │ ├── best: (scan kuvw@vw,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ ├── [ordering: +4 opt(2,3)] │ │ ├── best: (scan kuvw@uvw,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ ├── [ordering: +4,+3,+2] │ │ ├── best: (scan kuvw@wvu,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ └── [] │ ├── best: (scan kuvw,cols=(2-4)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G5: (aggregations G6) ├── G6: (array-agg G7) └── G7: (variable w) @@ -769,25 +769,25 @@ memo (optimized, ~5KB, required=[presentation: sum:5]) ├── G1: (project G2 G3 sum) │ └── [presentation: sum:5] │ ├── best: (project G2 G3 sum) - │ └── cost: 1130.00 + │ └── cost: 1130.03 ├── G2: (group-by G4 G5 cols=(2-4)) (group-by G4 G5 cols=(2-4),ordering=+2,+3,+4) (group-by G4 G5 cols=(2-4),ordering=+4,+3,+2) (group-by G4 G5 cols=(2-4),ordering=+3,+4) │ └── [] │ ├── best: (group-by G4="[ordering: +2,+3,+4]" G5 cols=(2-4),ordering=+2,+3,+4) - │ └── cost: 1120.00 + │ └── cost: 1120.02 ├── G3: (projections) ├── G4: (scan kuvw,cols=(2-4)) (scan kuvw@uvw,cols=(2-4)) (scan kuvw@wvu,cols=(2-4)) (scan kuvw@vw,cols=(2-4)) (scan kuvw@w,cols=(2-4)) │ ├── [ordering: +2,+3,+4] │ │ ├── best: (scan kuvw@uvw,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ ├── [ordering: +3,+4] │ │ ├── best: (scan kuvw@vw,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ ├── [ordering: +4,+3,+2] │ │ ├── best: (scan kuvw@wvu,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ └── [] │ ├── best: (scan kuvw,cols=(2-4)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G5: (aggregations G6) ├── G6: (sum G7) └── G7: (variable w) @@ -800,19 +800,19 @@ memo (optimized, ~5KB, required=[presentation: sum:5]) ├── G1: (project G2 G3 sum) │ └── [presentation: sum:5] │ ├── best: (project G2 G3 sum) - │ └── cost: 1082.00 + │ └── cost: 1082.03 ├── G2: (group-by G4 G5 cols=(3)) (group-by G4 G5 cols=(3),ordering=+3) │ └── [] │ ├── best: (group-by G4="[ordering: +3]" G5 cols=(3),ordering=+3) - │ └── cost: 1081.00 + │ └── cost: 1081.02 ├── G3: (projections) ├── G4: (scan kuvw,cols=(3,4)) (scan kuvw@uvw,cols=(3,4)) (scan kuvw@wvu,cols=(3,4)) (scan kuvw@vw,cols=(3,4)) (scan kuvw@w,cols=(3,4)) │ ├── [ordering: +3] │ │ ├── best: (scan kuvw@vw,cols=(3,4)) - │ │ └── cost: 1060.00 + │ │ └── cost: 1060.01 │ └── [] │ ├── best: (scan kuvw,cols=(3,4)) - │ └── cost: 1060.00 + │ └── cost: 1060.01 ├── G5: (aggregations G6) ├── G6: (sum G7) └── G7: (variable w) @@ -825,22 +825,22 @@ memo (optimized, ~5KB, required=[presentation: array_agg:5]) ├── G1: (project G2 G3 array_agg) │ └── [presentation: array_agg:5] │ ├── best: (project G2 G3 array_agg) - │ └── cost: 1102.00 + │ └── cost: 1102.03 ├── G2: (group-by G4 G5 cols=(3),ordering=+2,+4 opt(3)) (group-by G4 G5 cols=(3),ordering=+2,+3,+4) │ └── [] │ ├── best: (group-by G4="[ordering: +2,+4 opt(3)]" G5 cols=(3),ordering=+2,+4 opt(3)) - │ └── cost: 1101.00 + │ └── cost: 1101.02 ├── G3: (projections) ├── G4: (scan kuvw,cols=(2-4)) (scan kuvw@uvw,cols=(2-4)) (scan kuvw@wvu,cols=(2-4)) (scan kuvw@vw,cols=(2-4)) (scan kuvw@w,cols=(2-4)) │ ├── [ordering: +2,+3,+4] │ │ ├── best: (scan kuvw@uvw,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ ├── [ordering: +2,+4 opt(3)] │ │ ├── best: (scan kuvw@uvw,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ └── [] │ ├── best: (scan kuvw,cols=(2-4)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G5: (aggregations G6) ├── G6: (array-agg G7) └── G7: (variable w) @@ -853,78 +853,78 @@ memo (optimized, ~8KB, required=[presentation: array_agg:5]) ├── G1: (project G2 G3 array_agg) │ └── [presentation: array_agg:5] │ ├── best: (project G2 G3 array_agg) - │ └── cost: 1079.59 + │ └── cost: 1079.63 ├── G2: (group-by G4 G5 cols=(4),ordering=+(2|3) opt(4)) (group-by G4 G5 cols=(4),ordering=+(2|3)) (group-by G4 G5 cols=(4),ordering=+4,+(2|3)) (group-by G4 G5 cols=(4),ordering=+(2|3),+4) │ └── [] │ ├── best: (group-by G4="[ordering: +(2|3) opt(4)]" G5 cols=(4),ordering=+(2|3) opt(4)) - │ └── cost: 1079.50 + │ └── cost: 1079.53 ├── G3: (projections) ├── G4: (select G6 G7) (select G8 G7) (select G9 G7) │ ├── [ordering: +(2|3) opt(4)] │ │ ├── best: (select G8="[ordering: +2 opt(4)]" G7) - │ │ └── cost: 1079.10 + │ │ └── cost: 1079.12 │ ├── [ordering: +(2|3),+4] │ │ ├── best: (sort G4) - │ │ └── cost: 1080.01 + │ │ └── cost: 1080.04 │ ├── [ordering: +(2|3)] │ │ ├── best: (select G8="[ordering: +2]" G7) - │ │ └── cost: 1079.10 + │ │ └── cost: 1079.12 │ ├── [ordering: +4,+(2|3)] │ │ ├── best: (sort G4) - │ │ └── cost: 1080.01 + │ │ └── cost: 1080.04 │ └── [] │ ├── best: (select G8 G7) - │ └── cost: 1079.10 + │ └── cost: 1079.12 ├── G5: (aggregations G10) ├── G6: (scan kuvw) (scan kuvw@uvw) (scan kuvw@wvu) (scan kuvw@vw) (scan kuvw@w) │ ├── [ordering: +2 opt(4)] │ │ ├── best: (scan kuvw@uvw) - │ │ └── cost: 1080.00 + │ │ └── cost: 1080.01 │ ├── [ordering: +2,+4] │ │ ├── best: (sort G6) - │ │ └── cost: 1310.28 + │ │ └── cost: 1310.30 │ ├── [ordering: +2] │ │ ├── best: (scan kuvw@uvw) - │ │ └── cost: 1080.00 + │ │ └── cost: 1080.01 │ ├── [ordering: +4,+2] │ │ ├── best: (sort G6) - │ │ └── cost: 1310.28 + │ │ └── cost: 1310.30 │ └── [] │ ├── best: (scan kuvw) - │ └── cost: 1080.00 + │ └── cost: 1080.01 ├── G7: (filters G11) ├── G8: (scan kuvw@uvw,constrained) │ ├── [ordering: +2 opt(4)] │ │ ├── best: (scan kuvw@uvw,constrained) - │ │ └── cost: 1069.20 + │ │ └── cost: 1069.21 │ ├── [ordering: +2,+4] │ │ ├── best: (sort G8) - │ │ └── cost: 1296.88 + │ │ └── cost: 1296.90 │ ├── [ordering: +2] │ │ ├── best: (scan kuvw@uvw,constrained) - │ │ └── cost: 1069.20 + │ │ └── cost: 1069.21 │ ├── [ordering: +4,+2] │ │ ├── best: (sort G8) - │ │ └── cost: 1296.88 + │ │ └── cost: 1296.90 │ └── [] │ ├── best: (scan kuvw@uvw,constrained) - │ └── cost: 1069.20 + │ └── cost: 1069.21 ├── G9: (scan kuvw@vw,constrained) │ ├── [ordering: +2 opt(4)] │ │ ├── best: (sort G9) - │ │ └── cost: 1286.04 + │ │ └── cost: 1286.06 │ ├── [ordering: +2,+4] │ │ ├── best: (sort G9) - │ │ └── cost: 1296.88 + │ │ └── cost: 1296.90 │ ├── [ordering: +2] │ │ ├── best: (sort G9) - │ │ └── cost: 1286.04 + │ │ └── cost: 1286.06 │ ├── [ordering: +4,+2] │ │ ├── best: (sort G9) - │ │ └── cost: 1296.88 + │ │ └── cost: 1296.90 │ └── [] │ ├── best: (scan kuvw@vw,constrained) - │ └── cost: 1069.20 + │ └── cost: 1069.21 ├── G10: (array-agg G12) ├── G11: (eq G13 G14) ├── G12: (variable k) @@ -938,54 +938,54 @@ memo (optimized, ~8KB, required=[presentation: sum:5]) ├── G1: (project G2 G3 sum) │ └── [presentation: sum:5] │ ├── best: (project G2 G3 sum) - │ └── cost: 1079.65 + │ └── cost: 1079.69 ├── G2: (group-by G4 G5 cols=(2,4)) (group-by G4 G5 cols=(2,4),ordering=+(2|3)) (group-by G4 G5 cols=(2,4),ordering=+4) │ └── [] │ ├── best: (group-by G4="[ordering: +(2|3)]" G5 cols=(2,4),ordering=+(2|3)) - │ └── cost: 1079.55 + │ └── cost: 1079.58 ├── G3: (projections) ├── G4: (select G6 G7) (select G8 G7) (select G9 G7) │ ├── [ordering: +(2|3)] │ │ ├── best: (select G8="[ordering: +2]" G7) - │ │ └── cost: 1079.10 + │ │ └── cost: 1079.12 │ ├── [ordering: +4] │ │ ├── best: (sort G4) - │ │ └── cost: 1079.96 + │ │ └── cost: 1079.99 │ └── [] │ ├── best: (select G8 G7) - │ └── cost: 1079.10 + │ └── cost: 1079.12 ├── G5: (aggregations G10) ├── G6: (scan kuvw) (scan kuvw@uvw) (scan kuvw@wvu) (scan kuvw@vw) (scan kuvw@w) │ ├── [ordering: +2] │ │ ├── best: (scan kuvw@uvw) - │ │ └── cost: 1080.00 + │ │ └── cost: 1080.01 │ ├── [ordering: +4] │ │ ├── best: (scan kuvw@wvu) - │ │ └── cost: 1080.00 + │ │ └── cost: 1080.01 │ └── [] │ ├── best: (scan kuvw) - │ └── cost: 1080.00 + │ └── cost: 1080.01 ├── G7: (filters G11) ├── G8: (scan kuvw@uvw,constrained) │ ├── [ordering: +2] │ │ ├── best: (scan kuvw@uvw,constrained) - │ │ └── cost: 1069.20 + │ │ └── cost: 1069.21 │ ├── [ordering: +4] │ │ ├── best: (sort G8) - │ │ └── cost: 1286.04 + │ │ └── cost: 1286.06 │ └── [] │ ├── best: (scan kuvw@uvw,constrained) - │ └── cost: 1069.20 + │ └── cost: 1069.21 ├── G9: (scan kuvw@vw,constrained) │ ├── [ordering: +2] │ │ ├── best: (sort G9) - │ │ └── cost: 1286.04 + │ │ └── cost: 1286.06 │ ├── [ordering: +4] │ │ ├── best: (sort G9) - │ │ └── cost: 1286.04 + │ │ └── cost: 1286.06 │ └── [] │ ├── best: (scan kuvw@vw,constrained) - │ └── cost: 1069.20 + │ └── cost: 1069.21 ├── G10: (sum G12) ├── G11: (eq G13 G14) ├── G12: (variable k) @@ -1000,19 +1000,19 @@ memo (optimized, ~4KB, required=[presentation: array_agg:5]) ├── G1: (project G2 G3 array_agg) │ └── [presentation: array_agg:5] │ ├── best: (project G2 G3 array_agg) - │ └── cost: 1229.66 + │ └── cost: 1229.69 ├── G2: (group-by G4 G5 cols=(2,3),ordering=-4 opt(2,3)) │ └── [] │ ├── best: (group-by G4="[ordering: -4 opt(2,3)]" G5 cols=(2,3),ordering=-4 opt(2,3)) - │ └── cost: 1219.66 + │ └── cost: 1219.68 ├── G3: (projections) ├── G4: (scan kuvw,cols=(2-4)) (scan kuvw@uvw,cols=(2-4)) (scan kuvw@wvu,cols=(2-4)) (scan kuvw@vw,cols=(2-4)) (scan kuvw@w,cols=(2-4)) │ ├── [ordering: -4 opt(2,3)] │ │ ├── best: (scan kuvw@uvw,rev,cols=(2-4)) - │ │ └── cost: 1169.66 + │ │ └── cost: 1169.67 │ └── [] │ ├── best: (scan kuvw,cols=(2-4)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G5: (aggregations G6) ├── G6: (array-agg G7) └── G7: (variable w) @@ -1026,20 +1026,20 @@ memo (optimized, ~4KB, required=[presentation: u:2,v:3,w:4]) ├── G1: (distinct-on G2 G3 cols=(2-4)) (distinct-on G2 G3 cols=(2-4),ordering=+2,+3,+4) (distinct-on G2 G3 cols=(2-4),ordering=+4,+3,+2) (distinct-on G2 G3 cols=(2-4),ordering=+3,+4) │ └── [presentation: u:2,v:3,w:4] │ ├── best: (distinct-on G2="[ordering: +2,+3,+4]" G3 cols=(2-4),ordering=+2,+3,+4) - │ └── cost: 1110.00 + │ └── cost: 1110.02 ├── G2: (scan kuvw,cols=(2-4)) (scan kuvw@uvw,cols=(2-4)) (scan kuvw@wvu,cols=(2-4)) (scan kuvw@vw,cols=(2-4)) (scan kuvw@w,cols=(2-4)) │ ├── [ordering: +2,+3,+4] │ │ ├── best: (scan kuvw@uvw,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ ├── [ordering: +3,+4] │ │ ├── best: (scan kuvw@vw,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ ├── [ordering: +4,+3,+2] │ │ ├── best: (scan kuvw@wvu,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ └── [] │ ├── best: (scan kuvw,cols=(2-4)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 └── G3: (aggregations) # Orderings +u,+v and +v can be used. @@ -1050,17 +1050,17 @@ memo (optimized, ~4KB, required=[presentation: u:2,v:3,w:4]) ├── G1: (distinct-on G2 G3 cols=(2,3)) (distinct-on G2 G3 cols=(2,3),ordering=+2,+3) (distinct-on G2 G3 cols=(2,3),ordering=+3) │ └── [presentation: u:2,v:3,w:4] │ ├── best: (distinct-on G2="[ordering: +2,+3]" G3 cols=(2,3),ordering=+2,+3) - │ └── cost: 1110.00 + │ └── cost: 1110.02 ├── G2: (scan kuvw,cols=(2-4)) (scan kuvw@uvw,cols=(2-4)) (scan kuvw@wvu,cols=(2-4)) (scan kuvw@vw,cols=(2-4)) (scan kuvw@w,cols=(2-4)) │ ├── [ordering: +2,+3] │ │ ├── best: (scan kuvw@uvw,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ ├── [ordering: +3] │ │ ├── best: (scan kuvw@vw,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ └── [] │ ├── best: (scan kuvw,cols=(2-4)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G3: (aggregations G4) ├── G4: (first-agg G5) └── G5: (variable w) @@ -1073,14 +1073,14 @@ memo (optimized, ~4KB, required=[presentation: u:2,v:3,w:4]) ├── G1: (distinct-on G2 G3 cols=(2)) (distinct-on G2 G3 cols=(2),ordering=+2) │ └── [presentation: u:2,v:3,w:4] │ ├── best: (distinct-on G2="[ordering: +2]" G3 cols=(2),ordering=+2) - │ └── cost: 1101.00 + │ └── cost: 1101.02 ├── G2: (scan kuvw,cols=(2-4)) (scan kuvw@uvw,cols=(2-4)) (scan kuvw@wvu,cols=(2-4)) (scan kuvw@vw,cols=(2-4)) (scan kuvw@w,cols=(2-4)) │ ├── [ordering: +2] │ │ ├── best: (scan kuvw@uvw,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ └── [] │ ├── best: (scan kuvw,cols=(2-4)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G3: (aggregations G4 G5) ├── G4: (first-agg G6) ├── G5: (first-agg G7) @@ -1095,14 +1095,14 @@ memo (optimized, ~4KB, required=[presentation: u:2,v:3,w:4]) ├── G1: (distinct-on G2 G3 cols=(3)) (distinct-on G2 G3 cols=(3),ordering=+3) │ └── [presentation: u:2,v:3,w:4] │ ├── best: (distinct-on G2="[ordering: +3]" G3 cols=(3),ordering=+3) - │ └── cost: 1101.00 + │ └── cost: 1101.02 ├── G2: (scan kuvw,cols=(2-4)) (scan kuvw@uvw,cols=(2-4)) (scan kuvw@wvu,cols=(2-4)) (scan kuvw@vw,cols=(2-4)) (scan kuvw@w,cols=(2-4)) │ ├── [ordering: +3] │ │ ├── best: (scan kuvw@vw,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ └── [] │ ├── best: (scan kuvw,cols=(2-4)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G3: (aggregations G4 G5) ├── G4: (first-agg G6) ├── G5: (first-agg G7) @@ -1117,14 +1117,14 @@ memo (optimized, ~4KB, required=[presentation: u:2,v:3,w:4]) ├── G1: (distinct-on G2 G3 cols=(4)) (distinct-on G2 G3 cols=(4),ordering=+4) │ └── [presentation: u:2,v:3,w:4] │ ├── best: (distinct-on G2="[ordering: +4]" G3 cols=(4),ordering=+4) - │ └── cost: 1101.00 + │ └── cost: 1101.02 ├── G2: (scan kuvw,cols=(2-4)) (scan kuvw@uvw,cols=(2-4)) (scan kuvw@wvu,cols=(2-4)) (scan kuvw@vw,cols=(2-4)) (scan kuvw@w,cols=(2-4)) │ ├── [ordering: +4] │ │ ├── best: (scan kuvw@wvu,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ └── [] │ ├── best: (scan kuvw,cols=(2-4)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G3: (aggregations G4 G5) ├── G4: (first-agg G6) ├── G5: (first-agg G7) @@ -1139,23 +1139,23 @@ memo (optimized, ~4KB, required=[presentation: u:2,v:3,w:4] [ordering: +2]) ├── G1: (distinct-on G2 G3 cols=(2),ordering=+4 opt(2)) (distinct-on G2 G3 cols=(2),ordering=+4) │ ├── [presentation: u:2,v:3,w:4] [ordering: +2] │ │ ├── best: (sort G1) - │ │ └── cost: 1126.29 + │ │ └── cost: 1126.32 │ └── [] │ ├── best: (distinct-on G2="[ordering: +4 opt(2)]" G3 cols=(2),ordering=+4 opt(2)) - │ └── cost: 1111.00 + │ └── cost: 1111.02 ├── G2: (scan kuvw,cols=(2-4)) (scan kuvw@uvw,cols=(2-4)) (scan kuvw@wvu,cols=(2-4)) (scan kuvw@vw,cols=(2-4)) (scan kuvw@w,cols=(2-4)) │ ├── [ordering: +2,+4] │ │ ├── best: (sort G2) - │ │ └── cost: 1300.28 + │ │ └── cost: 1300.30 │ ├── [ordering: +4 opt(2)] │ │ ├── best: (scan kuvw@wvu,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ ├── [ordering: +4] │ │ ├── best: (scan kuvw@wvu,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ └── [] │ ├── best: (scan kuvw,cols=(2-4)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G3: (aggregations G4 G5) ├── G4: (first-agg G6) ├── G5: (first-agg G7) @@ -1170,23 +1170,23 @@ memo (optimized, ~4KB, required=[presentation: u:2,v:3,w:4] [ordering: +2]) ├── G1: (distinct-on G2 G3 cols=(2),ordering=+3,+4 opt(2)) (distinct-on G2 G3 cols=(2),ordering=+2,+3,+4) (distinct-on G2 G3 cols=(2),ordering=+3,+4) │ ├── [presentation: u:2,v:3,w:4] [ordering: +2] │ │ ├── best: (distinct-on G2="[ordering: +2,+3,+4]" G3 cols=(2),ordering=+3,+4 opt(2)) - │ │ └── cost: 1101.00 + │ │ └── cost: 1101.02 │ └── [] │ ├── best: (distinct-on G2="[ordering: +2,+3,+4]" G3 cols=(2),ordering=+2,+3,+4) - │ └── cost: 1101.00 + │ └── cost: 1101.02 ├── G2: (scan kuvw,cols=(2-4)) (scan kuvw@uvw,cols=(2-4)) (scan kuvw@wvu,cols=(2-4)) (scan kuvw@vw,cols=(2-4)) (scan kuvw@w,cols=(2-4)) │ ├── [ordering: +2,+3,+4] │ │ ├── best: (scan kuvw@uvw,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ ├── [ordering: +3,+4 opt(2)] │ │ ├── best: (scan kuvw@uvw,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ ├── [ordering: +3,+4] │ │ ├── best: (scan kuvw@vw,cols=(2-4)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ └── [] │ ├── best: (scan kuvw,cols=(2-4)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G3: (aggregations G4 G5) ├── G4: (first-agg G6) ├── G5: (first-agg G7) @@ -1201,20 +1201,20 @@ memo (optimized, ~3KB, required=[presentation: u:2,v:3,w:4] [ordering: +4,+2]) ├── G1: (distinct-on G2 G3 cols=(2,4),ordering=-3 opt(2,4)) │ ├── [presentation: u:2,v:3,w:4] [ordering: +4,+2] │ │ ├── best: (distinct-on G2="[ordering: +4,+2,-3]" G3 cols=(2,4),ordering=-3 opt(2,4)) - │ │ └── cost: 1341.38 + │ │ └── cost: 1341.41 │ └── [] │ ├── best: (distinct-on G2="[ordering: -3 opt(2,4)]" G3 cols=(2,4),ordering=-3 opt(2,4)) - │ └── cost: 1219.66 + │ └── cost: 1219.68 ├── G2: (scan kuvw,cols=(2-4)) (scan kuvw@uvw,cols=(2-4)) (scan kuvw@wvu,cols=(2-4)) (scan kuvw@vw,cols=(2-4)) (scan kuvw@w,cols=(2-4)) │ ├── [ordering: +4,+2,-3] │ │ ├── best: (sort G2) - │ │ └── cost: 1301.38 + │ │ └── cost: 1301.40 │ ├── [ordering: -3 opt(2,4)] │ │ ├── best: (scan kuvw@uvw,rev,cols=(2-4)) - │ │ └── cost: 1169.66 + │ │ └── cost: 1169.67 │ └── [] │ ├── best: (scan kuvw,cols=(2-4)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G3: (aggregations G4) ├── G4: (first-agg G5) └── G5: (variable v) @@ -1226,20 +1226,20 @@ memo (optimized, ~3KB, required=[presentation: u:2,v:3,w:4] [ordering: +4]) ├── G1: (distinct-on G2 G3 cols=(4),ordering=-2,+3 opt(4)) │ ├── [presentation: u:2,v:3,w:4] [ordering: +4] │ │ ├── best: (distinct-on G2="[ordering: +4,-2,+3]" G3 cols=(4),ordering=-2,+3 opt(4)) - │ │ └── cost: 1332.38 + │ │ └── cost: 1332.41 │ └── [] │ ├── best: (distinct-on G2="[ordering: -2,+3 opt(4)]" G3 cols=(4),ordering=-2,+3 opt(4)) - │ └── cost: 1341.28 + │ └── cost: 1341.31 ├── G2: (scan kuvw,cols=(2-4)) (scan kuvw@uvw,cols=(2-4)) (scan kuvw@wvu,cols=(2-4)) (scan kuvw@vw,cols=(2-4)) (scan kuvw@w,cols=(2-4)) │ ├── [ordering: +4,-2,+3] │ │ ├── best: (sort G2) - │ │ └── cost: 1301.38 + │ │ └── cost: 1301.40 │ ├── [ordering: -2,+3 opt(4)] │ │ ├── best: (sort G2) - │ │ └── cost: 1300.28 + │ │ └── cost: 1300.30 │ └── [] │ ├── best: (scan kuvw,cols=(2-4)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G3: (aggregations G4 G5) ├── G4: (first-agg G6) ├── G5: (first-agg G7) @@ -1253,20 +1253,20 @@ memo (optimized, ~3KB, required=[presentation: u:2,v:3,w:4] [ordering: -4]) ├── G1: (distinct-on G2 G3 cols=(4),ordering=-2,+3 opt(4)) │ ├── [presentation: u:2,v:3,w:4] [ordering: -4] │ │ ├── best: (distinct-on G2="[ordering: -4,-2,+3]" G3 cols=(4),ordering=-2,+3 opt(4)) - │ │ └── cost: 1332.38 + │ │ └── cost: 1332.41 │ └── [] │ ├── best: (distinct-on G2="[ordering: -2,+3 opt(4)]" G3 cols=(4),ordering=-2,+3 opt(4)) - │ └── cost: 1341.28 + │ └── cost: 1341.31 ├── G2: (scan kuvw,cols=(2-4)) (scan kuvw@uvw,cols=(2-4)) (scan kuvw@wvu,cols=(2-4)) (scan kuvw@vw,cols=(2-4)) (scan kuvw@w,cols=(2-4)) │ ├── [ordering: -2,+3 opt(4)] │ │ ├── best: (sort G2) - │ │ └── cost: 1300.28 + │ │ └── cost: 1300.30 │ ├── [ordering: -4,-2,+3] │ │ ├── best: (sort G2) - │ │ └── cost: 1301.38 + │ │ └── cost: 1301.40 │ └── [] │ ├── best: (scan kuvw,cols=(2-4)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G3: (aggregations G4 G5) ├── G4: (first-agg G6) ├── G5: (first-agg G7) @@ -1280,20 +1280,20 @@ memo (optimized, ~3KB, required=[presentation: u:2,v:3,w:4] [ordering: +4]) ├── G1: (distinct-on G2 G3 cols=(4),ordering=+2,-3 opt(4)) │ ├── [presentation: u:2,v:3,w:4] [ordering: +4] │ │ ├── best: (distinct-on G2="[ordering: +4,+2,-3]" G3 cols=(4),ordering=+2,-3 opt(4)) - │ │ └── cost: 1332.38 + │ │ └── cost: 1332.41 │ └── [] │ ├── best: (distinct-on G2="[ordering: +2,-3 opt(4)]" G3 cols=(4),ordering=+2,-3 opt(4)) - │ └── cost: 1341.28 + │ └── cost: 1341.31 ├── G2: (scan kuvw,cols=(2-4)) (scan kuvw@uvw,cols=(2-4)) (scan kuvw@wvu,cols=(2-4)) (scan kuvw@vw,cols=(2-4)) (scan kuvw@w,cols=(2-4)) │ ├── [ordering: +2,-3 opt(4)] │ │ ├── best: (sort G2) - │ │ └── cost: 1300.28 + │ │ └── cost: 1300.30 │ ├── [ordering: +4,+2,-3] │ │ ├── best: (sort G2) - │ │ └── cost: 1301.38 + │ │ └── cost: 1301.40 │ └── [] │ ├── best: (scan kuvw,cols=(2-4)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G3: (aggregations G4 G5) ├── G4: (first-agg G6) ├── G5: (first-agg G7) diff --git a/pkg/sql/opt/xform/testdata/rules/join b/pkg/sql/opt/xform/testdata/rules/join index 564cba34c481..5a9711c99a2f 100644 --- a/pkg/sql/opt/xform/testdata/rules/join +++ b/pkg/sql/opt/xform/testdata/rules/join @@ -90,21 +90,21 @@ memo (optimized, ~9KB, required=[presentation: a:1,b:2,c:3,x:5,y:6,z:7]) ├── G1: (inner-join G2 G3 G4) (inner-join G3 G2 G4) (merge-join G2 G3 G5 inner-join,+1,+7) (lookup-join G3 G5 abc@ab,keyCols=[7],outCols=(1-3,5-7)) │ └── [presentation: a:1,b:2,c:3,x:5,y:6,z:7] │ ├── best: (inner-join G2 G3 G4) - │ └── cost: 2270.00 + │ └── cost: 2270.03 ├── G2: (scan abc,cols=(1-3)) (scan abc@ab,cols=(1-3)) (scan abc@bc,cols=(1-3)) │ ├── [ordering: +1] │ │ ├── best: (scan abc@ab,cols=(1-3)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ └── [] │ ├── best: (scan abc,cols=(1-3)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G3: (scan xyz,cols=(5-7)) (scan xyz@xy,cols=(5-7)) (scan xyz@yz,cols=(5-7)) │ ├── [ordering: +7] │ │ ├── best: (sort G3) - │ │ └── cost: 1289.32 + │ │ └── cost: 1289.34 │ └── [] │ ├── best: (scan xyz,cols=(5-7)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G4: (filters G6) ├── G5: (filters) ├── G6: (eq G7 G8) @@ -118,21 +118,21 @@ memo (optimized, ~8KB, required=[presentation: a:1,b:2,c:3,x:5,y:6,z:7]) ├── G1: (full-join G2 G3 G4) (full-join G3 G2 G4) (merge-join G2 G3 G5 full-join,+1,+7) │ └── [presentation: a:1,b:2,c:3,x:5,y:6,z:7] │ ├── best: (full-join G2 G3 G4) - │ └── cost: 2270.00 + │ └── cost: 2270.03 ├── G2: (scan abc,cols=(1-3)) (scan abc@ab,cols=(1-3)) (scan abc@bc,cols=(1-3)) │ ├── [ordering: +1] │ │ ├── best: (scan abc@ab,cols=(1-3)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ └── [] │ ├── best: (scan abc,cols=(1-3)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G3: (scan xyz,cols=(5-7)) (scan xyz@xy,cols=(5-7)) (scan xyz@yz,cols=(5-7)) │ ├── [ordering: +7] │ │ ├── best: (sort G3) - │ │ └── cost: 1289.32 + │ │ └── cost: 1289.34 │ └── [] │ ├── best: (scan xyz,cols=(5-7)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G4: (filters G6) ├── G5: (filters) ├── G6: (eq G7 G8) @@ -185,21 +185,21 @@ memo (optimized, ~8KB, required=[presentation: a:1,b:2,c:3,x:5,y:6,z:7]) ├── G1: (left-join G2 G3 G4) (right-join G3 G2 G4) (merge-join G2 G3 G5 left-join,+1,+7) │ └── [presentation: a:1,b:2,c:3,x:5,y:6,z:7] │ ├── best: (left-join G2 G3 G4) - │ └── cost: 2270.00 + │ └── cost: 2270.03 ├── G2: (scan abc,cols=(1-3)) (scan abc@ab,cols=(1-3)) (scan abc@bc,cols=(1-3)) │ ├── [ordering: +1] │ │ ├── best: (scan abc@ab,cols=(1-3)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ └── [] │ ├── best: (scan abc,cols=(1-3)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G3: (scan xyz,cols=(5-7)) (scan xyz@xy,cols=(5-7)) (scan xyz@yz,cols=(5-7)) │ ├── [ordering: +7] │ │ ├── best: (sort G3) - │ │ └── cost: 1289.32 + │ │ └── cost: 1289.34 │ └── [] │ ├── best: (scan xyz,cols=(5-7)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G4: (filters G6) ├── G5: (filters) ├── G6: (eq G7 G8) @@ -232,21 +232,21 @@ memo (optimized, ~9KB, required=[presentation: a:1,b:2,c:3,x:5,y:6,z:7]) ├── G1: (right-join G2 G3 G4) (left-join G3 G2 G4) (merge-join G2 G3 G5 right-join,+1,+7) (lookup-join G3 G5 abc@ab,keyCols=[7],outCols=(1-3,5-7)) │ └── [presentation: a:1,b:2,c:3,x:5,y:6,z:7] │ ├── best: (right-join G2 G3 G4) - │ └── cost: 2270.00 + │ └── cost: 2270.03 ├── G2: (scan abc,cols=(1-3)) (scan abc@ab,cols=(1-3)) (scan abc@bc,cols=(1-3)) │ ├── [ordering: +1] │ │ ├── best: (scan abc@ab,cols=(1-3)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ └── [] │ ├── best: (scan abc,cols=(1-3)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G3: (scan xyz,cols=(5-7)) (scan xyz@xy,cols=(5-7)) (scan xyz@yz,cols=(5-7)) │ ├── [ordering: +7] │ │ ├── best: (sort G3) - │ │ └── cost: 1289.32 + │ │ └── cost: 1289.34 │ └── [] │ ├── best: (scan xyz,cols=(5-7)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G4: (filters G6) ├── G5: (filters) ├── G6: (eq G7 G8) @@ -295,21 +295,21 @@ memo (optimized, ~10KB, required=[presentation: a:1,b:2,c:3,x:5,y:6,z:7]) ├── G1: (inner-join G2 G3 G4) (inner-join G3 G2 G4) (merge-join G2 G3 G5 inner-join,+1,+5) (lookup-join G2 G5 xyz@xy,keyCols=[1],outCols=(1-3,5-7)) (merge-join G3 G2 G5 inner-join,+5,+1) (lookup-join G3 G5 abc@ab,keyCols=[5],outCols=(1-3,5-7)) │ └── [presentation: a:1,b:2,c:3,x:5,y:6,z:7] │ ├── best: (merge-join G2="[ordering: +1]" G3="[ordering: +5]" G5 inner-join,+1,+5) - │ └── cost: 2260.00 + │ └── cost: 2260.03 ├── G2: (scan abc,cols=(1-3)) (scan abc@ab,cols=(1-3)) (scan abc@bc,cols=(1-3)) │ ├── [ordering: +1] │ │ ├── best: (scan abc@ab,cols=(1-3)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ └── [] │ ├── best: (scan abc,cols=(1-3)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G3: (scan xyz,cols=(5-7)) (scan xyz@xy,cols=(5-7)) (scan xyz@yz,cols=(5-7)) │ ├── [ordering: +5] │ │ ├── best: (scan xyz@xy,cols=(5-7)) - │ │ └── cost: 1070.00 + │ │ └── cost: 1070.01 │ └── [] │ ├── best: (scan xyz,cols=(5-7)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G4: (filters G6) ├── G5: (filters) ├── G6: (eq G7 G8) @@ -376,27 +376,27 @@ memo (optimized, ~9KB, required=[presentation: s:1,t:2,u:3,s:4,t:5,u:6]) ├── G1: (inner-join G2 G3 G4) (inner-join G3 G2 G4) (merge-join G2 G3 G5 inner-join,+1,+2,+3,+4,+5,+6) (merge-join G2 G3 G5 inner-join,+3,+2,+1,+6,+5,+4) (lookup-join G2 G5 stu,keyCols=[1 2 3],outCols=(1-6)) (lookup-join G2 G5 stu@uts,keyCols=[3 2 1],outCols=(1-6)) (merge-join G3 G2 G5 inner-join,+4,+5,+6,+1,+2,+3) (merge-join G3 G2 G5 inner-join,+6,+5,+4,+3,+2,+1) (lookup-join G3 G5 stu,keyCols=[4 5 6],outCols=(1-6)) (lookup-join G3 G5 stu@uts,keyCols=[6 5 4],outCols=(1-6)) │ └── [presentation: s:1,t:2,u:3,s:4,t:5,u:6] │ ├── best: (merge-join G2="[ordering: +1,+2,+3]" G3="[ordering: +4,+5,+6]" G5 inner-join,+1,+2,+3,+4,+5,+6) - │ └── cost: 2140.01 + │ └── cost: 2140.04 ├── G2: (scan stu) (scan stu@uts) │ ├── [ordering: +1,+2,+3] │ │ ├── best: (scan stu) - │ │ └── cost: 1060.00 + │ │ └── cost: 1060.01 │ ├── [ordering: +3,+2,+1] │ │ ├── best: (scan stu@uts) - │ │ └── cost: 1060.00 + │ │ └── cost: 1060.01 │ └── [] │ ├── best: (scan stu) - │ └── cost: 1060.00 + │ └── cost: 1060.01 ├── G3: (scan stu) (scan stu@uts) │ ├── [ordering: +4,+5,+6] │ │ ├── best: (scan stu) - │ │ └── cost: 1060.00 + │ │ └── cost: 1060.01 │ ├── [ordering: +6,+5,+4] │ │ ├── best: (scan stu@uts) - │ │ └── cost: 1060.00 + │ │ └── cost: 1060.01 │ └── [] │ ├── best: (scan stu) - │ └── cost: 1060.00 + │ └── cost: 1060.01 ├── G4: (filters G6 G7 G8) ├── G5: (filters) ├── G6: (eq G9 G10) @@ -579,29 +579,29 @@ memo (optimized, ~11KB, required=[presentation: a:1,b:2,c:3,x:5,y:6,z:7]) ├── G1: (inner-join G2 G3 G4) (inner-join G3 G2 G4) │ └── [presentation: a:1,b:2,c:3,x:5,y:6,z:7] │ ├── best: (inner-join G3 G2 G4) - │ └── cost: 2251.88 + │ └── cost: 2251.91 ├── G2: (select G5 G6) (select G7 G6) (select G8 G6) │ └── [] │ ├── best: (select G7 G6) - │ └── cost: 1069.20 + │ └── cost: 1069.22 ├── G3: (scan xyz,cols=(5-7)) (scan xyz@xy,cols=(5-7)) (scan xyz@yz,cols=(5-7)) │ └── [] │ ├── best: (scan xyz,cols=(5-7)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G4: (filters) ├── G5: (scan abc,cols=(1-3)) (scan abc@ab,cols=(1-3)) (scan abc@bc,cols=(1-3)) │ └── [] │ ├── best: (scan abc,cols=(1-3)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G6: (filters G9) ├── G7: (scan abc@ab,cols=(1-3),constrained) │ └── [] │ ├── best: (scan abc@ab,cols=(1-3),constrained) - │ └── cost: 1059.30 + │ └── cost: 1059.31 ├── G8: (scan abc@bc,cols=(1-3),constrained) │ └── [] │ ├── best: (scan abc@bc,cols=(1-3),constrained) - │ └── cost: 1059.30 + │ └── cost: 1059.31 ├── G9: (eq G10 G11) ├── G10: (variable a) └── G11: (variable b) @@ -621,15 +621,15 @@ memo (optimized, ~5KB, required=[presentation: a:1,b:2,c:3,k:5]) ├── G1: (inner-join G2 G3 G4) (inner-join G3 G2 G4) │ └── [presentation: a:1,b:2,c:3,k:5] │ ├── best: (inner-join G2 G3 G4) - │ └── cost: 2130.00 + │ └── cost: 2130.03 ├── G2: (scan abc,cols=(1-3)) (scan abc@ab,cols=(1-3)) (scan abc@bc,cols=(1-3)) │ └── [] │ ├── best: (scan abc,cols=(1-3)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G3: (scan kfloat) │ └── [] │ ├── best: (scan kfloat) - │ └── cost: 1020.00 + │ └── cost: 1020.01 ├── G4: (filters G5) ├── G5: (eq G6 G7) ├── G6: (variable a) diff --git a/pkg/sql/opt/xform/testdata/rules/limit b/pkg/sql/opt/xform/testdata/rules/limit index 61d1718cbe96..a1829d875fef 100644 --- a/pkg/sql/opt/xform/testdata/rules/limit +++ b/pkg/sql/opt/xform/testdata/rules/limit @@ -122,16 +122,16 @@ memo (optimized, ~6KB, required=[presentation: s:4]) ├── G1: (limit G2 G3) (scan a@s_idx,cols=(4),constrained,lim=1) (scan a@si_idx,cols=(4),constrained,lim=1) │ └── [presentation: s:4] │ ├── best: (scan a@s_idx,cols=(4),constrained,lim=1) - │ └── cost: 1.05 + │ └── cost: 1.06 ├── G2: (select G4 G5) (scan a@s_idx,cols=(4),constrained) (scan a@si_idx,cols=(4),constrained) │ └── [] │ ├── best: (scan a@s_idx,cols=(4),constrained) - │ └── cost: 10.40 + │ └── cost: 10.41 ├── G3: (const 1) ├── G4: (scan a,cols=(4)) (scan a@s_idx,cols=(4)) (scan a@si_idx,cols=(4)) │ └── [] │ ├── best: (scan a@s_idx,cols=(4)) - │ └── cost: 1050.00 + │ └── cost: 1050.01 ├── G5: (filters G6) ├── G6: (eq G7 G8) ├── G7: (variable s) diff --git a/pkg/sql/opt/xform/testdata/rules/scan b/pkg/sql/opt/xform/testdata/rules/scan index ca1b3cb1a094..d663157225b4 100644 --- a/pkg/sql/opt/xform/testdata/rules/scan +++ b/pkg/sql/opt/xform/testdata/rules/scan @@ -77,17 +77,17 @@ memo (optimized, ~3KB, required=[presentation: k:1,f:3] [ordering: -1]) ├── G1: (limit G2 G3 ordering=-1) (scan a,rev,cols=(1,3),lim=10(rev)) │ ├── [presentation: k:1,f:3] [ordering: -1] │ │ ├── best: (scan a,rev,cols=(1,3),lim=10(rev)) - │ │ └── cost: 11.03 + │ │ └── cost: 11.04 │ └── [] │ ├── best: (scan a,rev,cols=(1,3),lim=10(rev)) - │ └── cost: 11.03 + │ └── cost: 11.04 ├── G2: (scan a,cols=(1,3)) (scan a@s_idx,cols=(1,3)) │ ├── [ordering: -1] │ │ ├── best: (scan a,rev,cols=(1,3)) - │ │ └── cost: 1169.66 + │ │ └── cost: 1169.67 │ └── [] │ ├── best: (scan a@s_idx,cols=(1,3)) - │ └── cost: 1060.00 + │ └── cost: 1060.01 └── G3: (const 10) @@ -171,10 +171,10 @@ memo (optimized, ~2KB, required=[presentation: k:1] [ordering: +1]) └── G1: (scan a,cols=(1)) (scan a@s_idx,cols=(1)) (scan a@si_idx,cols=(1)) ├── [presentation: k:1] [ordering: +1] │ ├── best: (scan a,cols=(1)) - │ └── cost: 1060.00 + │ └── cost: 1060.01 └── [] ├── best: (scan a@s_idx,cols=(1)) - └── cost: 1050.00 + └── cost: 1050.01 # Scan of secondary index is lowest cost. opt @@ -193,10 +193,10 @@ memo (optimized, ~2KB, required=[presentation: s:4,i:2,f:3] [ordering: +4,+1]) └── G1: (scan a,cols=(1-4)) (scan a@s_idx,cols=(1-4)) ├── [presentation: s:4,i:2,f:3] [ordering: +4,+1] │ ├── best: (scan a@s_idx,cols=(1-4)) - │ └── cost: 1080.00 + │ └── cost: 1080.01 └── [] ├── best: (scan a@s_idx,cols=(1-4)) - └── cost: 1080.00 + └── cost: 1080.01 # No index-join should be generated for a@si_idx, since it is not constrained. exploretrace rule=GenerateIndexScans @@ -285,10 +285,10 @@ memo (optimized, ~2KB, required=[presentation: s:4,i:2,f:3] [ordering: +3]) └── G1: (scan a,cols=(2-4)) (scan a@s_idx,cols=(2-4)) ├── [presentation: s:4,i:2,f:3] [ordering: +3] │ ├── best: (sort G1) - │ └── cost: 1289.32 + │ └── cost: 1289.34 └── [] ├── best: (scan a@s_idx,cols=(2-4)) - └── cost: 1070.00 + └── cost: 1070.01 memo SELECT s, i, f FROM a ORDER BY s DESC, i @@ -297,10 +297,10 @@ memo (optimized, ~2KB, required=[presentation: s:4,i:2,f:3] [ordering: -4,+2]) └── G1: (scan a,cols=(2-4)) (scan a@s_idx,cols=(2-4)) ├── [presentation: s:4,i:2,f:3] [ordering: -4,+2] │ ├── best: (sort G1) - │ └── cost: 1300.28 + │ └── cost: 1300.30 └── [] ├── best: (scan a@s_idx,cols=(2-4)) - └── cost: 1070.00 + └── cost: 1070.01 memo SELECT s, i, f FROM a WHERE s='foo' ORDER BY s DESC, i @@ -309,25 +309,25 @@ memo (optimized, ~5KB, required=[presentation: s:4,i:2,f:3] [ordering: +2 opt(4) ├── G1: (select G2 G3) (scan a@s_idx,cols=(2-4),constrained) (index-join G4 a,cols=(2-4)) │ ├── [presentation: s:4,i:2,f:3] [ordering: +2 opt(4)] │ │ ├── best: (sort G1) - │ │ └── cost: 11.45 + │ │ └── cost: 11.47 │ └── [] │ ├── best: (scan a@s_idx,cols=(2-4),constrained) - │ └── cost: 10.59 + │ └── cost: 10.60 ├── G2: (scan a,cols=(2-4)) (scan a@s_idx,cols=(2-4)) │ ├── [ordering: +2 opt(4)] │ │ ├── best: (sort G2) - │ │ └── cost: 1289.32 + │ │ └── cost: 1289.34 │ └── [] │ ├── best: (scan a@s_idx,cols=(2-4)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G3: (filters G5) ├── G4: (scan a@si_idx,cols=(1,2,4),constrained) │ ├── [ordering: +2 opt(4)] │ │ ├── best: (scan a@si_idx,rev,cols=(1,2,4),constrained) - │ │ └── cost: 10.92 + │ │ └── cost: 10.93 │ └── [] │ ├── best: (scan a@si_idx,cols=(1,2,4),constrained) - │ └── cost: 10.59 + │ └── cost: 10.60 ├── G5: (eq G6 G7) ├── G6: (variable s) └── G7: (const 'foo') @@ -384,14 +384,14 @@ memo (optimized, ~3KB, required=[presentation: d:4] [ordering: +5]) ├── G1: (project G2 G3 d) │ ├── [presentation: d:4] [ordering: +5] │ │ ├── best: (sort G1) - │ │ └── cost: 1289.32 + │ │ └── cost: 1289.35 │ └── [] │ ├── best: (project G2 G3 d) - │ └── cost: 1070.00 + │ └── cost: 1070.02 ├── G2: (scan abc,cols=(4)) │ └── [] │ ├── best: (scan abc,cols=(4)) - │ └── cost: 1050.00 + │ └── cost: 1050.01 ├── G3: (projections G4) ├── G4: (function G5 lower) ├── G5: (scalar-list G6) @@ -404,21 +404,21 @@ memo (optimized, ~6KB, required=[presentation: j:5]) ├── G1: (project G2 G3 j) │ └── [presentation: j:5] │ ├── best: (project G2 G3 j) - │ └── cost: 10.59 + │ └── cost: 10.61 ├── G2: (select G4 G5) (index-join G6 a,cols=(4,5)) (scan a@si_idx,cols=(4,5),constrained) │ └── [] │ ├── best: (scan a@si_idx,cols=(4,5),constrained) - │ └── cost: 10.49 + │ └── cost: 10.50 ├── G3: (projections) ├── G4: (scan a,cols=(4,5)) (scan a@si_idx,cols=(4,5)) │ └── [] │ ├── best: (scan a@si_idx,cols=(4,5)) - │ └── cost: 1060.00 + │ └── cost: 1060.01 ├── G5: (filters G7) ├── G6: (scan a@s_idx,cols=(1,4),constrained) │ └── [] │ ├── best: (scan a@s_idx,cols=(1,4),constrained) - │ └── cost: 10.49 + │ └── cost: 10.50 ├── G7: (eq G8 G9) ├── G8: (variable s) └── G9: (const 'foo') @@ -440,10 +440,10 @@ memo (optimized, ~2KB, required=[presentation: s:4,i:2,f:3] [ordering: +1]) └── G1: (scan a,cols=(1-4)) (scan a@s_idx,cols=(1-4)) ├── [presentation: s:4,i:2,f:3] [ordering: +1] │ ├── best: (scan a,cols=(1-4)) - │ └── cost: 1090.00 + │ └── cost: 1090.01 └── [] ├── best: (scan a@s_idx,cols=(1-4)) - └── cost: 1080.00 + └── cost: 1080.01 # Secondary index has right order opt @@ -460,10 +460,10 @@ memo (optimized, ~2KB, required=[presentation: s:4,j:5] [ordering: +4]) └── G1: (scan a,cols=(4,5)) (scan a@si_idx,cols=(4,5)) ├── [presentation: s:4,j:5] [ordering: +4] │ ├── best: (scan a@si_idx,rev,cols=(4,5)) - │ └── cost: 1159.66 + │ └── cost: 1159.67 └── [] ├── best: (scan a@si_idx,cols=(4,5)) - └── cost: 1060.00 + └── cost: 1060.01 # Consider three different indexes, and pick index with multiple keys. opt @@ -486,10 +486,10 @@ memo (optimized, ~2KB, required=[presentation: i:2,k:1] [ordering: -4,+2,+1]) └── G1: (scan a,cols=(1,2,4)) (scan a@s_idx,cols=(1,2,4)) (scan a@si_idx,cols=(1,2,4)) ├── [presentation: i:2,k:1] [ordering: -4,+2,+1] │ ├── best: (sort G1) - │ └── cost: 1301.38 + │ └── cost: 1301.40 └── [] ├── best: (scan a@s_idx,cols=(1,2,4)) - └── cost: 1070.00 + └── cost: 1070.01 memo SELECT i, k FROM a WHERE s >= 'foo' @@ -498,16 +498,16 @@ memo (optimized, ~5KB, required=[presentation: i:2,k:1]) ├── G1: (project G2 G3 k i) │ └── [presentation: i:2,k:1] │ ├── best: (project G2 G3 k i) - │ └── cost: 356.40 + │ └── cost: 356.42 ├── G2: (select G4 G5) (scan a@s_idx,cols=(1,2,4),constrained) (scan a@si_idx,cols=(1,2,4),constrained) │ └── [] │ ├── best: (scan a@s_idx,cols=(1,2,4),constrained) - │ └── cost: 353.10 + │ └── cost: 353.11 ├── G3: (projections) ├── G4: (scan a,cols=(1,2,4)) (scan a@s_idx,cols=(1,2,4)) (scan a@si_idx,cols=(1,2,4)) │ └── [] │ ├── best: (scan a@s_idx,cols=(1,2,4)) - │ └── cost: 1070.00 + │ └── cost: 1070.01 ├── G5: (filters G6) ├── G6: (ge G7 G8) ├── G7: (variable s) diff --git a/pkg/sql/opt/xform/testdata/rules/select b/pkg/sql/opt/xform/testdata/rules/select index 150f70c94444..5dcda18ec100 100644 --- a/pkg/sql/opt/xform/testdata/rules/select +++ b/pkg/sql/opt/xform/testdata/rules/select @@ -73,11 +73,11 @@ memo (optimized, ~4KB, required=[presentation: k:1]) ├── G1: (select G2 G3) (scan a,cols=(1),constrained) │ └── [presentation: k:1] │ ├── best: (scan a,cols=(1),constrained) - │ └── cost: 1.04 + │ └── cost: 1.05 ├── G2: (scan a,cols=(1)) (scan a@u,cols=(1)) (scan a@v,cols=(1)) │ └── [] │ ├── best: (scan a,cols=(1)) - │ └── cost: 1040.00 + │ └── cost: 1040.01 ├── G3: (filters G4) ├── G4: (eq G5 G6) ├── G5: (variable k) @@ -102,16 +102,16 @@ memo (optimized, ~5KB, required=[presentation: k:1]) ├── G1: (project G2 G3 k) │ └── [presentation: k:1] │ ├── best: (project G2 G3 k) - │ └── cost: 349.80 + │ └── cost: 349.82 ├── G2: (select G4 G5) (scan a@v,cols=(1,3),constrained) │ └── [] │ ├── best: (scan a@v,cols=(1,3),constrained) - │ └── cost: 346.50 + │ └── cost: 346.51 ├── G3: (projections) ├── G4: (scan a,cols=(1,3)) (scan a@u,cols=(1,3)) (scan a@v,cols=(1,3)) │ └── [] │ ├── best: (scan a,cols=(1,3)) - │ └── cost: 1050.00 + │ └── cost: 1050.01 ├── G5: (filters G6) ├── G6: (gt G7 G8) ├── G7: (variable v) @@ -139,21 +139,21 @@ memo (optimized, ~6KB, required=[presentation: k:1]) ├── G1: (project G2 G3 k) │ └── [presentation: k:1] │ ├── best: (project G2 G3 k) - │ └── cost: 1.05 + │ └── cost: 1.07 ├── G2: (select G4 G5) (select G6 G7) (scan a@u,cols=(1,2),constrained) │ └── [] │ ├── best: (scan a@u,cols=(1,2),constrained) - │ └── cost: 1.04 + │ └── cost: 1.05 ├── G3: (projections) ├── G4: (scan a,cols=(1,2)) (scan a@u,cols=(1,2)) (scan a@v,cols=(1,2)) │ └── [] │ ├── best: (scan a,cols=(1,2)) - │ └── cost: 1050.00 + │ └── cost: 1050.01 ├── G5: (filters G8 G9) ├── G6: (scan a,cols=(1,2),constrained) │ └── [] │ ├── best: (scan a,cols=(1,2),constrained) - │ └── cost: 1.05 + │ └── cost: 1.06 ├── G7: (filters G8) ├── G8: (eq G10 G11) ├── G9: (eq G12 G13) @@ -188,21 +188,21 @@ memo (optimized, ~6KB, required=[presentation: k:1]) ├── G1: (project G2 G3 k) │ └── [presentation: k:1] │ ├── best: (project G2 G3 k) - │ └── cost: 10.53 + │ └── cost: 10.56 ├── G2: (select G4 G5) (select G6 G7) │ └── [] │ ├── best: (select G6 G7) - │ └── cost: 10.49 + │ └── cost: 10.51 ├── G3: (projections) ├── G4: (scan a,cols=(1,2)) (scan a@u,cols=(1,2)) (scan a@v,cols=(1,2)) │ └── [] │ ├── best: (scan a,cols=(1,2)) - │ └── cost: 1050.00 + │ └── cost: 1050.01 ├── G5: (filters G8 G9) ├── G6: (scan a@u,cols=(1,2),constrained) │ └── [] │ ├── best: (scan a@u,cols=(1,2),constrained) - │ └── cost: 10.40 + │ └── cost: 10.41 ├── G7: (filters G9) ├── G8: (eq G10 G11) ├── G9: (eq G12 G11) @@ -240,26 +240,26 @@ memo (optimized, ~5KB, required=[presentation: k:1]) ├── G1: (project G2 G3 k) │ └── [presentation: k:1] │ ├── best: (project G2 G3 k) - │ └── cost: 1.07 + │ └── cost: 1.10 ├── G2: (select G4 G5) (select G6 G7) (select G8 G9) │ └── [] │ ├── best: (select G8 G9) - │ └── cost: 1.07 + │ └── cost: 1.09 ├── G3: (projections) ├── G4: (scan a) (scan a@u) (scan a@v) │ └── [] │ ├── best: (scan a) - │ └── cost: 1060.00 + │ └── cost: 1060.01 ├── G5: (filters G10 G11) ├── G6: (scan a@u,constrained) │ └── [] │ ├── best: (scan a@u,constrained) - │ └── cost: 10.49 + │ └── cost: 10.50 ├── G7: (filters G11) ├── G8: (scan a@v,constrained) │ └── [] │ ├── best: (scan a@v,constrained) - │ └── cost: 1.06 + │ └── cost: 1.07 ├── G9: (filters G10) ├── G10: (eq G12 G13) ├── G11: (eq G14 G15) @@ -330,16 +330,16 @@ memo (optimized, ~3KB, required=[presentation: k:1,u:2,v:3,j:4]) ├── G1: (select G2 G3) (index-join G4 b,cols=(1-4)) │ └── [presentation: k:1,u:2,v:3,j:4] │ ├── best: (index-join G4 b,cols=(1-4)) - │ └── cost: 51.30 + │ └── cost: 51.32 ├── G2: (scan b) │ └── [] │ ├── best: (scan b) - │ └── cost: 1080.00 + │ └── cost: 1080.01 ├── G3: (filters G5 G6) ├── G4: (scan b@v,cols=(1,3),constrained) │ └── [] │ ├── best: (scan b@v,cols=(1,3),constrained) - │ └── cost: 10.40 + │ └── cost: 10.41 ├── G5: (ge G7 G8) ├── G6: (le G7 G9) ├── G7: (variable v) @@ -387,28 +387,28 @@ memo (optimized, ~5KB, required=[presentation: k:1,u:2,v:3,j:4]) ├── G1: (select G2 G3) (select G4 G5) (index-join G6 b,cols=(1-4)) │ └── [presentation: k:1,u:2,v:3,j:4] │ ├── best: (index-join G6 b,cols=(1-4)) - │ └── cost: 24.13 + │ └── cost: 24.16 ├── G2: (scan b) │ └── [] │ ├── best: (scan b) - │ └── cost: 1080.00 + │ └── cost: 1080.01 ├── G3: (filters G7 G8 G9) ├── G4: (scan b,constrained) │ └── [] │ ├── best: (scan b,constrained) - │ └── cost: 360.00 + │ └── cost: 360.01 ├── G5: (filters G7 G8) ├── G6: (select G10 G11) │ └── [] │ ├── best: (select G10 G11) - │ └── cost: 10.50 + │ └── cost: 10.52 ├── G7: (ge G12 G13) ├── G8: (le G12 G14) ├── G9: (gt G15 G16) ├── G10: (scan b@v,cols=(1,3),constrained) │ └── [] │ ├── best: (scan b@v,cols=(1,3),constrained) - │ └── cost: 10.40 + │ └── cost: 10.41 ├── G11: (filters G9) ├── G12: (variable v) ├── G13: (const 1) @@ -479,16 +479,16 @@ memo (optimized, ~4KB, required=[presentation: k:1,u:2,v:3,j:4]) ├── G1: (select G2 G3) (select G4 G5) │ └── [presentation: k:1,u:2,v:3,j:4] │ ├── best: (select G4 G5) - │ └── cost: 51.40 + │ └── cost: 51.43 ├── G2: (scan b) │ └── [] │ ├── best: (scan b) - │ └── cost: 1080.00 + │ └── cost: 1080.01 ├── G3: (filters G6 G7 G8) ├── G4: (index-join G9 b,cols=(1-4)) │ └── [] │ ├── best: (index-join G9 b,cols=(1-4)) - │ └── cost: 51.30 + │ └── cost: 51.32 ├── G5: (filters G8) ├── G6: (ge G10 G11) ├── G7: (le G10 G12) @@ -496,7 +496,7 @@ memo (optimized, ~4KB, required=[presentation: k:1,u:2,v:3,j:4]) ├── G9: (scan b@v,cols=(1,3),constrained) │ └── [] │ ├── best: (scan b@v,cols=(1,3),constrained) - │ └── cost: 10.40 + │ └── cost: 10.41 ├── G10: (variable v) ├── G11: (const 1) ├── G12: (const 10) @@ -536,21 +536,21 @@ memo (optimized, ~6KB, required=[presentation: k:1,u:2,v:3,j:4]) ├── G1: (select G2 G3) (select G4 G5) (select G6 G7) │ └── [presentation: k:1,u:2,v:3,j:4] │ ├── best: (select G6 G7) - │ └── cost: 24.17 + │ └── cost: 24.21 ├── G2: (scan b) │ └── [] │ ├── best: (scan b) - │ └── cost: 1080.00 + │ └── cost: 1080.01 ├── G3: (filters G8 G9 G10 G11) ├── G4: (scan b,constrained) │ └── [] │ ├── best: (scan b,constrained) - │ └── cost: 360.00 + │ └── cost: 360.01 ├── G5: (filters G8 G9 G10) ├── G6: (index-join G12 b,cols=(1-4)) │ └── [] │ ├── best: (index-join G12 b,cols=(1-4)) - │ └── cost: 24.13 + │ └── cost: 24.16 ├── G7: (filters G10) ├── G8: (ge G13 G14) ├── G9: (le G13 G15) @@ -559,7 +559,7 @@ memo (optimized, ~6KB, required=[presentation: k:1,u:2,v:3,j:4]) ├── G12: (select G19 G20) │ └── [] │ ├── best: (select G19 G20) - │ └── cost: 10.50 + │ └── cost: 10.52 ├── G13: (variable v) ├── G14: (const 1) ├── G15: (const 10) @@ -569,7 +569,7 @@ memo (optimized, ~6KB, required=[presentation: k:1,u:2,v:3,j:4]) ├── G19: (scan b@v,cols=(1,3),constrained) │ └── [] │ ├── best: (scan b@v,cols=(1,3),constrained) - │ └── cost: 10.40 + │ └── cost: 10.41 ├── G20: (filters G11) └── G21: (variable u) @@ -601,22 +601,22 @@ memo (optimized, ~4KB, required=[presentation: k:1,u:2,v:3,j:4]) ├── G1: (select G2 G3) (select G4 G3) │ └── [presentation: k:1,u:2,v:3,j:4] │ ├── best: (select G4 G3) - │ └── cost: 45.23 + │ └── cost: 45.26 ├── G2: (scan b) │ └── [] │ ├── best: (scan b) - │ └── cost: 1080.00 + │ └── cost: 1080.01 ├── G3: (filters G5 G6) ├── G4: (index-join G7 b,cols=(1-4)) │ └── [] │ ├── best: (index-join G7 b,cols=(1-4)) - │ └── cost: 45.14 + │ └── cost: 45.16 ├── G5: (gt G8 G9) ├── G6: (lt G8 G10) ├── G7: (scan b@u,cols=(1,2),constrained) │ └── [] │ ├── best: (scan b@u,cols=(1,2),constrained) - │ └── cost: 9.15 + │ └── cost: 9.16 ├── G8: (tuple G11) ├── G9: (tuple G12) ├── G10: (tuple G13)