github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/opt/xform/testdata/rules/combo (about) 1 exec-ddl 2 CREATE TABLE abc 3 ( 4 a INT, 5 b INT, 6 c INT, 7 INDEX ab (a,b) STORING (c) 8 ) 9 ---- 10 11 exec-ddl 12 CREATE TABLE xyz 13 ( 14 x INT, 15 y INT, 16 z INT, 17 INDEX xy (x,y) STORING (z) 18 ) 19 ---- 20 21 # -------------------------------------------------- 22 # Use exploretrace. 23 # -------------------------------------------------- 24 exploretrace 25 SELECT * FROM abc, xyz WHERE a=x AND b=y 26 ---- 27 ---- 28 ================================================================================ 29 GenerateIndexScans 30 ================================================================================ 31 Source expression: 32 inner-join (hash) 33 ├── columns: a:1!null b:2!null c:3 x:5!null y:6!null z:7 34 ├── fd: (1)==(5), (5)==(1), (2)==(6), (6)==(2) 35 ├── scan abc 36 │ └── columns: a:1 b:2 c:3 37 ├── scan xyz 38 │ └── columns: x:5 y:6 z:7 39 └── filters 40 ├── a:1 = x:5 [outer=(1,5), constraints=(/1: (/NULL - ]; /5: (/NULL - ]), fd=(1)==(5), (5)==(1)] 41 └── b:2 = y:6 [outer=(2,6), constraints=(/2: (/NULL - ]; /6: (/NULL - ]), fd=(2)==(6), (6)==(2)] 42 43 New expression 1 of 1: 44 inner-join (hash) 45 ├── columns: a:1!null b:2!null c:3 x:5!null y:6!null z:7 46 ├── fd: (1)==(5), (5)==(1), (2)==(6), (6)==(2) 47 ├── scan abc@ab 48 │ └── columns: a:1 b:2 c:3 49 ├── scan xyz 50 │ └── columns: x:5 y:6 z:7 51 └── filters 52 ├── a:1 = x:5 [outer=(1,5), constraints=(/1: (/NULL - ]; /5: (/NULL - ]), fd=(1)==(5), (5)==(1)] 53 └── b:2 = y:6 [outer=(2,6), constraints=(/2: (/NULL - ]; /6: (/NULL - ]), fd=(2)==(6), (6)==(2)] 54 55 ================================================================================ 56 GenerateIndexScans 57 ================================================================================ 58 Source expression: 59 inner-join (hash) 60 ├── columns: a:1!null b:2!null c:3 x:5!null y:6!null z:7 61 ├── fd: (1)==(5), (5)==(1), (2)==(6), (6)==(2) 62 ├── scan abc 63 │ └── columns: a:1 b:2 c:3 64 ├── scan xyz 65 │ └── columns: x:5 y:6 z:7 66 └── filters 67 ├── a:1 = x:5 [outer=(1,5), constraints=(/1: (/NULL - ]; /5: (/NULL - ]), fd=(1)==(5), (5)==(1)] 68 └── b:2 = y:6 [outer=(2,6), constraints=(/2: (/NULL - ]; /6: (/NULL - ]), fd=(2)==(6), (6)==(2)] 69 70 New expression 1 of 1: 71 inner-join (hash) 72 ├── columns: a:1!null b:2!null c:3 x:5!null y:6!null z:7 73 ├── fd: (1)==(5), (5)==(1), (2)==(6), (6)==(2) 74 ├── scan abc 75 │ └── columns: a:1 b:2 c:3 76 ├── scan xyz@xy 77 │ └── columns: x:5 y:6 z:7 78 └── filters 79 ├── a:1 = x:5 [outer=(1,5), constraints=(/1: (/NULL - ]; /5: (/NULL - ]), fd=(1)==(5), (5)==(1)] 80 └── b:2 = y:6 [outer=(2,6), constraints=(/2: (/NULL - ]; /6: (/NULL - ]), fd=(2)==(6), (6)==(2)] 81 82 ================================================================================ 83 CommuteJoin 84 ================================================================================ 85 Source expression: 86 inner-join (hash) 87 ├── columns: a:1!null b:2!null c:3 x:5!null y:6!null z:7 88 ├── fd: (1)==(5), (5)==(1), (2)==(6), (6)==(2) 89 ├── scan abc 90 │ └── columns: a:1 b:2 c:3 91 ├── scan xyz 92 │ └── columns: x:5 y:6 z:7 93 └── filters 94 ├── a:1 = x:5 [outer=(1,5), constraints=(/1: (/NULL - ]; /5: (/NULL - ]), fd=(1)==(5), (5)==(1)] 95 └── b:2 = y:6 [outer=(2,6), constraints=(/2: (/NULL - ]; /6: (/NULL - ]), fd=(2)==(6), (6)==(2)] 96 97 New expression 1 of 1: 98 inner-join (hash) 99 ├── columns: a:1!null b:2!null c:3 x:5!null y:6!null z:7 100 ├── fd: (1)==(5), (5)==(1), (2)==(6), (6)==(2) 101 ├── scan xyz 102 │ └── columns: x:5 y:6 z:7 103 ├── scan abc 104 │ └── columns: a:1 b:2 c:3 105 └── filters 106 ├── a:1 = x:5 [outer=(1,5), constraints=(/1: (/NULL - ]; /5: (/NULL - ]), fd=(1)==(5), (5)==(1)] 107 └── b:2 = y:6 [outer=(2,6), constraints=(/2: (/NULL - ]; /6: (/NULL - ]), fd=(2)==(6), (6)==(2)] 108 109 ================================================================================ 110 GenerateMergeJoins 111 ================================================================================ 112 Source expression: 113 inner-join (hash) 114 ├── columns: a:1!null b:2!null c:3 x:5!null y:6!null z:7 115 ├── fd: (1)==(5), (5)==(1), (2)==(6), (6)==(2) 116 ├── scan abc 117 │ └── columns: a:1 b:2 c:3 118 ├── scan xyz 119 │ └── columns: x:5 y:6 z:7 120 └── filters 121 ├── a:1 = x:5 [outer=(1,5), constraints=(/1: (/NULL - ]; /5: (/NULL - ]), fd=(1)==(5), (5)==(1)] 122 └── b:2 = y:6 [outer=(2,6), constraints=(/2: (/NULL - ]; /6: (/NULL - ]), fd=(2)==(6), (6)==(2)] 123 124 New expression 1 of 1: 125 inner-join (merge) 126 ├── columns: a:1!null b:2!null c:3 x:5!null y:6!null z:7 127 ├── left ordering: +1,+2 128 ├── right ordering: +5,+6 129 ├── fd: (1)==(5), (5)==(1), (2)==(6), (6)==(2) 130 ├── scan abc@ab 131 │ ├── columns: a:1 b:2 c:3 132 │ └── ordering: +1,+2 133 ├── scan xyz@xy 134 │ ├── columns: x:5 y:6 z:7 135 │ └── ordering: +5,+6 136 └── filters (true) 137 138 ================================================================================ 139 GenerateLookupJoins 140 ================================================================================ 141 Source expression: 142 inner-join (hash) 143 ├── columns: a:1!null b:2!null c:3 x:5!null y:6!null z:7 144 ├── fd: (1)==(5), (5)==(1), (2)==(6), (6)==(2) 145 ├── scan abc 146 │ └── columns: a:1 b:2 c:3 147 ├── scan xyz 148 │ └── columns: x:5 y:6 z:7 149 └── filters 150 ├── a:1 = x:5 [outer=(1,5), constraints=(/1: (/NULL - ]; /5: (/NULL - ]), fd=(1)==(5), (5)==(1)] 151 └── b:2 = y:6 [outer=(2,6), constraints=(/2: (/NULL - ]; /6: (/NULL - ]), fd=(2)==(6), (6)==(2)] 152 153 New expression 1 of 1: 154 inner-join (lookup xyz@xy) 155 ├── columns: a:1!null b:2!null c:3 x:5!null y:6!null z:7 156 ├── key columns: [1 2] = [5 6] 157 ├── fd: (1)==(5), (5)==(1), (2)==(6), (6)==(2) 158 ├── scan abc 159 │ └── columns: a:1 b:2 c:3 160 └── filters (true) 161 162 ================================================================================ 163 CommuteJoin 164 ================================================================================ 165 Source expression: 166 inner-join (hash) 167 ├── columns: a:1!null b:2!null c:3 x:5!null y:6!null z:7 168 ├── fd: (1)==(5), (5)==(1), (2)==(6), (6)==(2) 169 ├── scan xyz 170 │ └── columns: x:5 y:6 z:7 171 ├── scan abc 172 │ └── columns: a:1 b:2 c:3 173 └── filters 174 ├── a:1 = x:5 [outer=(1,5), constraints=(/1: (/NULL - ]; /5: (/NULL - ]), fd=(1)==(5), (5)==(1)] 175 └── b:2 = y:6 [outer=(2,6), constraints=(/2: (/NULL - ]; /6: (/NULL - ]), fd=(2)==(6), (6)==(2)] 176 177 No new expressions. 178 179 ================================================================================ 180 GenerateMergeJoins 181 ================================================================================ 182 Source expression: 183 inner-join (hash) 184 ├── columns: a:1!null b:2!null c:3 x:5!null y:6!null z:7 185 ├── fd: (1)==(5), (5)==(1), (2)==(6), (6)==(2) 186 ├── scan xyz 187 │ └── columns: x:5 y:6 z:7 188 ├── scan abc 189 │ └── columns: a:1 b:2 c:3 190 └── filters 191 ├── a:1 = x:5 [outer=(1,5), constraints=(/1: (/NULL - ]; /5: (/NULL - ]), fd=(1)==(5), (5)==(1)] 192 └── b:2 = y:6 [outer=(2,6), constraints=(/2: (/NULL - ]; /6: (/NULL - ]), fd=(2)==(6), (6)==(2)] 193 194 New expression 1 of 1: 195 inner-join (merge) 196 ├── columns: a:1!null b:2!null c:3 x:5!null y:6!null z:7 197 ├── left ordering: +5,+6 198 ├── right ordering: +1,+2 199 ├── fd: (1)==(5), (5)==(1), (2)==(6), (6)==(2) 200 ├── scan xyz@xy 201 │ ├── columns: x:5 y:6 z:7 202 │ └── ordering: +5,+6 203 ├── scan abc@ab 204 │ ├── columns: a:1 b:2 c:3 205 │ └── ordering: +1,+2 206 └── filters (true) 207 208 ================================================================================ 209 GenerateLookupJoins 210 ================================================================================ 211 Source expression: 212 inner-join (hash) 213 ├── columns: a:1!null b:2!null c:3 x:5!null y:6!null z:7 214 ├── fd: (1)==(5), (5)==(1), (2)==(6), (6)==(2) 215 ├── scan xyz 216 │ └── columns: x:5 y:6 z:7 217 ├── scan abc 218 │ └── columns: a:1 b:2 c:3 219 └── filters 220 ├── a:1 = x:5 [outer=(1,5), constraints=(/1: (/NULL - ]; /5: (/NULL - ]), fd=(1)==(5), (5)==(1)] 221 └── b:2 = y:6 [outer=(2,6), constraints=(/2: (/NULL - ]; /6: (/NULL - ]), fd=(2)==(6), (6)==(2)] 222 223 New expression 1 of 1: 224 inner-join (lookup abc@ab) 225 ├── columns: a:1!null b:2!null c:3 x:5!null y:6!null z:7 226 ├── key columns: [5 6] = [1 2] 227 ├── fd: (1)==(5), (5)==(1), (2)==(6), (6)==(2) 228 ├── scan xyz 229 │ └── columns: x:5 y:6 z:7 230 └── filters (true) 231 ---- 232 ----