github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/opt/norm/testdata/rules/combo (about) 1 exec-ddl 2 CREATE TABLE a ( 3 k INT PRIMARY KEY, 4 i INT, 5 f FLOAT, 6 s STRING, 7 j JSON, 8 UNIQUE INDEX (s DESC, f) STORING (j) 9 ) 10 ---- 11 12 exec-ddl 13 CREATE TABLE t.xy (x INT PRIMARY KEY, y INT) 14 ---- 15 16 # -------------------------------------------------- 17 # Use optsteps. 18 # -------------------------------------------------- 19 optsteps 20 SELECT s FROM a INNER JOIN xy ON a.k=xy.x AND i+1=10 21 ---- 22 ================================================================================ 23 Initial expression 24 Cost: 15503.40 25 ================================================================================ 26 project 27 ├── columns: s:4 28 └── inner-join (cross) 29 ├── columns: k:1!null i:2 f:3 s:4 j:5 x:6!null y:7 30 ├── key: (1,6) 31 ├── fd: (1)-->(2-5), (3,4)~~>(1,2,5), (6)-->(7) 32 ├── scan a 33 │ ├── columns: k:1!null i:2 f:3 s:4 j:5 34 │ ├── key: (1) 35 │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 36 ├── scan xy 37 │ ├── columns: x:6!null y:7 38 │ ├── key: (6) 39 │ └── fd: (6)-->(7) 40 └── filters 41 └── (k:1 = x:6) AND ((i:2 + 1) = 10) [outer=(1,2,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ])] 42 ================================================================================ 43 NormalizeCmpPlusConst 44 Cost: 15470.07 45 ================================================================================ 46 project 47 ├── columns: s:4 48 └── inner-join (cross) 49 - ├── columns: k:1!null i:2 f:3 s:4 j:5 x:6!null y:7 50 + ├── columns: k:1!null i:2!null f:3 s:4 j:5 x:6!null y:7 51 ├── key: (1,6) 52 ├── fd: (1)-->(2-5), (3,4)~~>(1,2,5), (6)-->(7) 53 ├── scan a 54 │ ├── columns: k:1!null i:2 f:3 s:4 j:5 55 │ ├── key: (1) 56 │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 57 ├── scan xy 58 │ ├── columns: x:6!null y:7 59 │ ├── key: (6) 60 │ └── fd: (6)-->(7) 61 └── filters 62 - └── (k:1 = x:6) AND ((i:2 + 1) = 10) [outer=(1,2,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ])] 63 + └── (k:1 = x:6) AND (i:2 = (10 - 1)) [outer=(1,2,6), constraints=(/1: (/NULL - ]; /2: (/NULL - ]; /6: (/NULL - ])] 64 ================================================================================ 65 FoldBinary 66 Cost: 12203.40 67 ================================================================================ 68 project 69 ├── columns: s:4 70 └── inner-join (cross) 71 ├── columns: k:1!null i:2!null f:3 s:4 j:5 x:6!null y:7 72 ├── key: (1,6) 73 - ├── fd: (1)-->(2-5), (3,4)~~>(1,2,5), (6)-->(7) 74 + ├── fd: ()-->(2), (1)-->(3-5), (3,4)~~>(1,5), (6)-->(7) 75 ├── scan a 76 │ ├── columns: k:1!null i:2 f:3 s:4 j:5 77 │ ├── key: (1) 78 │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 79 ├── scan xy 80 │ ├── columns: x:6!null y:7 81 │ ├── key: (6) 82 │ └── fd: (6)-->(7) 83 └── filters 84 - └── (k:1 = x:6) AND (i:2 = (10 - 1)) [outer=(1,2,6), constraints=(/1: (/NULL - ]; /2: (/NULL - ]; /6: (/NULL - ])] 85 + └── (k:1 = x:6) AND (i:2 = 9) [outer=(1,2,6), constraints=(/1: (/NULL - ]; /2: [/9 - /9]; /6: (/NULL - ]), fd=()-->(2)] 86 ================================================================================ 87 SimplifyJoinFilters 88 Cost: 2180.17 89 ================================================================================ 90 project 91 ├── columns: s:4 92 - └── inner-join (cross) 93 + └── inner-join (hash) 94 ├── columns: k:1!null i:2!null f:3 s:4 j:5 x:6!null y:7 95 - ├── key: (1,6) 96 - ├── fd: ()-->(2), (1)-->(3-5), (3,4)~~>(1,5), (6)-->(7) 97 + ├── key: (6) 98 + ├── fd: ()-->(2), (1)-->(3-5), (3,4)~~>(1,5), (6)-->(7), (1)==(6), (6)==(1) 99 ├── scan a 100 │ ├── columns: k:1!null i:2 f:3 s:4 j:5 101 │ ├── key: (1) 102 │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 103 ├── scan xy 104 │ ├── columns: x:6!null y:7 105 │ ├── key: (6) 106 │ └── fd: (6)-->(7) 107 └── filters 108 - └── (k:1 = x:6) AND (i:2 = 9) [outer=(1,2,6), constraints=(/1: (/NULL - ]; /2: [/9 - /9]; /6: (/NULL - ]), fd=()-->(2)] 109 + ├── k:1 = x:6 [outer=(1,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ]), fd=(1)==(6), (6)==(1)] 110 + └── i:2 = 9 [outer=(2), constraints=(/2: [/9 - /9]; tight), fd=()-->(2)] 111 ================================================================================ 112 PushFilterIntoJoinLeft 113 Cost: 2167.90 114 ================================================================================ 115 project 116 ├── columns: s:4 117 └── inner-join (hash) 118 ├── columns: k:1!null i:2!null f:3 s:4 j:5 x:6!null y:7 119 ├── key: (6) 120 ├── fd: ()-->(2), (1)-->(3-5), (3,4)~~>(1,5), (6)-->(7), (1)==(6), (6)==(1) 121 - ├── scan a 122 - │ ├── columns: k:1!null i:2 f:3 s:4 j:5 123 + ├── select 124 + │ ├── columns: k:1!null i:2!null f:3 s:4 j:5 125 │ ├── key: (1) 126 - │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 127 + │ ├── fd: ()-->(2), (1)-->(3-5), (3,4)~~>(1,5) 128 + │ ├── scan a 129 + │ │ ├── columns: k:1!null i:2 f:3 s:4 j:5 130 + │ │ ├── key: (1) 131 + │ │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 132 + │ └── filters 133 + │ └── i:2 = 9 [outer=(2), constraints=(/2: [/9 - /9]; tight), fd=()-->(2)] 134 ├── scan xy 135 │ ├── columns: x:6!null y:7 136 │ ├── key: (6) 137 │ └── fd: (6)-->(7) 138 └── filters 139 - ├── k:1 = x:6 [outer=(1,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ]), fd=(1)==(6), (6)==(1)] 140 - └── i:2 = 9 [outer=(2), constraints=(/2: [/9 - /9]; tight), fd=()-->(2)] 141 + └── k:1 = x:6 [outer=(1,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ]), fd=(1)==(6), (6)==(1)] 142 ================================================================================ 143 PruneJoinLeftCols 144 Cost: 2168.01 145 ================================================================================ 146 project 147 ├── columns: s:4 148 └── inner-join (hash) 149 - ├── columns: k:1!null i:2!null f:3 s:4 j:5 x:6!null y:7 150 + ├── columns: k:1!null i:2!null s:4 x:6!null y:7 151 ├── key: (6) 152 - ├── fd: ()-->(2), (1)-->(3-5), (3,4)~~>(1,5), (6)-->(7), (1)==(6), (6)==(1) 153 - ├── select 154 - │ ├── columns: k:1!null i:2!null f:3 s:4 j:5 155 + ├── fd: ()-->(2), (1)-->(4), (6)-->(7), (1)==(6), (6)==(1) 156 + ├── project 157 + │ ├── columns: k:1!null i:2!null s:4 158 │ ├── key: (1) 159 - │ ├── fd: ()-->(2), (1)-->(3-5), (3,4)~~>(1,5) 160 - │ ├── scan a 161 - │ │ ├── columns: k:1!null i:2 f:3 s:4 j:5 162 - │ │ ├── key: (1) 163 - │ │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 164 - │ └── filters 165 - │ └── i:2 = 9 [outer=(2), constraints=(/2: [/9 - /9]; tight), fd=()-->(2)] 166 + │ ├── fd: ()-->(2), (1)-->(4) 167 + │ └── select 168 + │ ├── columns: k:1!null i:2!null f:3 s:4 j:5 169 + │ ├── key: (1) 170 + │ ├── fd: ()-->(2), (1)-->(3-5), (3,4)~~>(1,5) 171 + │ ├── scan a 172 + │ │ ├── columns: k:1!null i:2 f:3 s:4 j:5 173 + │ │ ├── key: (1) 174 + │ │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 175 + │ └── filters 176 + │ └── i:2 = 9 [outer=(2), constraints=(/2: [/9 - /9]; tight), fd=()-->(2)] 177 ├── scan xy 178 │ ├── columns: x:6!null y:7 179 │ ├── key: (6) 180 │ └── fd: (6)-->(7) 181 └── filters 182 └── k:1 = x:6 [outer=(1,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ]), fd=(1)==(6), (6)==(1)] 183 ================================================================================ 184 PruneSelectCols 185 Cost: 2148.01 186 ================================================================================ 187 project 188 ├── columns: s:4 189 └── inner-join (hash) 190 ├── columns: k:1!null i:2!null s:4 x:6!null y:7 191 ├── key: (6) 192 ├── fd: ()-->(2), (1)-->(4), (6)-->(7), (1)==(6), (6)==(1) 193 ├── project 194 │ ├── columns: k:1!null i:2!null s:4 195 │ ├── key: (1) 196 │ ├── fd: ()-->(2), (1)-->(4) 197 │ └── select 198 - │ ├── columns: k:1!null i:2!null f:3 s:4 j:5 199 + │ ├── columns: k:1!null i:2!null s:4 200 │ ├── key: (1) 201 - │ ├── fd: ()-->(2), (1)-->(3-5), (3,4)~~>(1,5) 202 + │ ├── fd: ()-->(2), (1)-->(4) 203 │ ├── scan a 204 - │ │ ├── columns: k:1!null i:2 f:3 s:4 j:5 205 + │ │ ├── columns: k:1!null i:2 s:4 206 │ │ ├── key: (1) 207 - │ │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 208 + │ │ └── fd: (1)-->(2,4) 209 │ └── filters 210 │ └── i:2 = 9 [outer=(2), constraints=(/2: [/9 - /9]; tight), fd=()-->(2)] 211 ├── scan xy 212 │ ├── columns: x:6!null y:7 213 │ ├── key: (6) 214 │ └── fd: (6)-->(7) 215 └── filters 216 └── k:1 = x:6 [outer=(1,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ]), fd=(1)==(6), (6)==(1)] 217 ================================================================================ 218 EliminateProject 219 Cost: 2147.90 220 ================================================================================ 221 project 222 ├── columns: s:4 223 └── inner-join (hash) 224 ├── columns: k:1!null i:2!null s:4 x:6!null y:7 225 ├── key: (6) 226 ├── fd: ()-->(2), (1)-->(4), (6)-->(7), (1)==(6), (6)==(1) 227 - ├── project 228 + ├── select 229 │ ├── columns: k:1!null i:2!null s:4 230 │ ├── key: (1) 231 │ ├── fd: ()-->(2), (1)-->(4) 232 - │ └── select 233 - │ ├── columns: k:1!null i:2!null s:4 234 - │ ├── key: (1) 235 - │ ├── fd: ()-->(2), (1)-->(4) 236 - │ ├── scan a 237 - │ │ ├── columns: k:1!null i:2 s:4 238 - │ │ ├── key: (1) 239 - │ │ └── fd: (1)-->(2,4) 240 - │ └── filters 241 - │ └── i:2 = 9 [outer=(2), constraints=(/2: [/9 - /9]; tight), fd=()-->(2)] 242 + │ ├── scan a 243 + │ │ ├── columns: k:1!null i:2 s:4 244 + │ │ ├── key: (1) 245 + │ │ └── fd: (1)-->(2,4) 246 + │ └── filters 247 + │ └── i:2 = 9 [outer=(2), constraints=(/2: [/9 - /9]; tight), fd=()-->(2)] 248 ├── scan xy 249 │ ├── columns: x:6!null y:7 250 │ ├── key: (6) 251 │ └── fd: (6)-->(7) 252 └── filters 253 └── k:1 = x:6 [outer=(1,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ]), fd=(1)==(6), (6)==(1)] 254 ================================================================================ 255 PruneJoinRightCols 256 Cost: 2137.90 257 ================================================================================ 258 project 259 ├── columns: s:4 260 └── inner-join (hash) 261 - ├── columns: k:1!null i:2!null s:4 x:6!null y:7 262 + ├── columns: k:1!null i:2!null s:4 x:6!null 263 ├── key: (6) 264 - ├── fd: ()-->(2), (1)-->(4), (6)-->(7), (1)==(6), (6)==(1) 265 + ├── fd: ()-->(2), (1)-->(4), (1)==(6), (6)==(1) 266 ├── select 267 │ ├── columns: k:1!null i:2!null s:4 268 │ ├── key: (1) 269 │ ├── fd: ()-->(2), (1)-->(4) 270 │ ├── scan a 271 │ │ ├── columns: k:1!null i:2 s:4 272 │ │ ├── key: (1) 273 │ │ └── fd: (1)-->(2,4) 274 │ └── filters 275 │ └── i:2 = 9 [outer=(2), constraints=(/2: [/9 - /9]; tight), fd=()-->(2)] 276 ├── scan xy 277 - │ ├── columns: x:6!null y:7 278 - │ ├── key: (6) 279 - │ └── fd: (6)-->(7) 280 + │ ├── columns: x:6!null 281 + │ └── key: (6) 282 └── filters 283 └── k:1 = x:6 [outer=(1,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ]), fd=(1)==(6), (6)==(1)] 284 -------------------------------------------------------------------------------- 285 GenerateIndexScans (no changes) 286 -------------------------------------------------------------------------------- 287 -------------------------------------------------------------------------------- 288 GenerateZigzagJoins (no changes) 289 -------------------------------------------------------------------------------- 290 -------------------------------------------------------------------------------- 291 GenerateConstrainedScans (no changes) 292 -------------------------------------------------------------------------------- 293 -------------------------------------------------------------------------------- 294 GenerateIndexScans (no changes) 295 -------------------------------------------------------------------------------- 296 ================================================================================ 297 CommuteJoin 298 Cost: 2132.95 299 ================================================================================ 300 project 301 ├── columns: s:4 302 └── inner-join (hash) 303 ├── columns: k:1!null i:2!null s:4 x:6!null 304 ├── key: (6) 305 ├── fd: ()-->(2), (1)-->(4), (1)==(6), (6)==(1) 306 + ├── scan xy 307 + │ ├── columns: x:6!null 308 + │ └── key: (6) 309 ├── select 310 │ ├── columns: k:1!null i:2!null s:4 311 │ ├── key: (1) 312 │ ├── fd: ()-->(2), (1)-->(4) 313 │ ├── scan a 314 │ │ ├── columns: k:1!null i:2 s:4 315 │ │ ├── key: (1) 316 │ │ └── fd: (1)-->(2,4) 317 │ └── filters 318 │ └── i:2 = 9 [outer=(2), constraints=(/2: [/9 - /9]; tight), fd=()-->(2)] 319 - ├── scan xy 320 - │ ├── columns: x:6!null 321 - │ └── key: (6) 322 └── filters 323 └── k:1 = x:6 [outer=(1,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ]), fd=(1)==(6), (6)==(1)] 324 ================================================================================ 325 GenerateMergeJoins 326 Cost: 2130.37 327 ================================================================================ 328 project 329 ├── columns: s:4 330 - └── inner-join (hash) 331 + └── inner-join (merge) 332 ├── columns: k:1!null i:2!null s:4 x:6!null 333 + ├── left ordering: +1 334 + ├── right ordering: +6 335 ├── key: (6) 336 ├── fd: ()-->(2), (1)-->(4), (1)==(6), (6)==(1) 337 - ├── scan xy 338 - │ ├── columns: x:6!null 339 - │ └── key: (6) 340 ├── select 341 │ ├── columns: k:1!null i:2!null s:4 342 │ ├── key: (1) 343 │ ├── fd: ()-->(2), (1)-->(4) 344 + │ ├── ordering: +1 opt(2) [actual: +1] 345 │ ├── scan a 346 │ │ ├── columns: k:1!null i:2 s:4 347 │ │ ├── key: (1) 348 - │ │ └── fd: (1)-->(2,4) 349 + │ │ ├── fd: (1)-->(2,4) 350 + │ │ └── ordering: +1 opt(2) [actual: +1] 351 │ └── filters 352 │ └── i:2 = 9 [outer=(2), constraints=(/2: [/9 - /9]; tight), fd=()-->(2)] 353 - └── filters 354 - └── k:1 = x:6 [outer=(1,6), constraints=(/1: (/NULL - ]; /6: (/NULL - ]), fd=(1)==(6), (6)==(1)] 355 + ├── scan xy 356 + │ ├── columns: x:6!null 357 + │ ├── key: (6) 358 + │ └── ordering: +6 359 + └── filters (true) 360 ================================================================================ 361 GenerateLookupJoins 362 Cost: 1150.45 363 ================================================================================ 364 project 365 ├── columns: s:4 366 - └── inner-join (merge) 367 + └── inner-join (lookup xy) 368 ├── columns: k:1!null i:2!null s:4 x:6!null 369 - ├── left ordering: +1 370 - ├── right ordering: +6 371 + ├── key columns: [1] = [6] 372 + ├── lookup columns are key 373 ├── key: (6) 374 ├── fd: ()-->(2), (1)-->(4), (1)==(6), (6)==(1) 375 ├── select 376 │ ├── columns: k:1!null i:2!null s:4 377 │ ├── key: (1) 378 │ ├── fd: ()-->(2), (1)-->(4) 379 - │ ├── ordering: +1 opt(2) [actual: +1] 380 │ ├── scan a 381 │ │ ├── columns: k:1!null i:2 s:4 382 │ │ ├── key: (1) 383 - │ │ ├── fd: (1)-->(2,4) 384 - │ │ └── ordering: +1 opt(2) [actual: +1] 385 + │ │ └── fd: (1)-->(2,4) 386 │ └── filters 387 │ └── i:2 = 9 [outer=(2), constraints=(/2: [/9 - /9]; tight), fd=()-->(2)] 388 - ├── scan xy 389 - │ ├── columns: x:6!null 390 - │ ├── key: (6) 391 - │ └── ordering: +6 392 └── filters (true) 393 -------------------------------------------------------------------------------- 394 CommuteJoin (no changes) 395 -------------------------------------------------------------------------------- 396 -------------------------------------------------------------------------------- 397 GenerateMergeJoins (higher cost) 398 -------------------------------------------------------------------------------- 399 project 400 ├── columns: s:4 401 - └── inner-join (lookup xy) 402 + └── inner-join (merge) 403 ├── columns: k:1!null i:2!null s:4 x:6!null 404 - ├── key columns: [1] = [6] 405 - ├── lookup columns are key 406 + ├── left ordering: +6 407 + ├── right ordering: +1 408 ├── key: (6) 409 ├── fd: ()-->(2), (1)-->(4), (1)==(6), (6)==(1) 410 + ├── scan xy 411 + │ ├── columns: x:6!null 412 + │ ├── key: (6) 413 + │ └── ordering: +6 414 ├── select 415 │ ├── columns: k:1!null i:2!null s:4 416 │ ├── key: (1) 417 │ ├── fd: ()-->(2), (1)-->(4) 418 + │ ├── ordering: +1 opt(2) [actual: +1] 419 │ ├── scan a 420 │ │ ├── columns: k:1!null i:2 s:4 421 │ │ ├── key: (1) 422 - │ │ └── fd: (1)-->(2,4) 423 + │ │ ├── fd: (1)-->(2,4) 424 + │ │ └── ordering: +1 opt(2) [actual: +1] 425 │ └── filters 426 │ └── i:2 = 9 [outer=(2), constraints=(/2: [/9 - /9]; tight), fd=()-->(2)] 427 └── filters (true) 428 -------------------------------------------------------------------------------- 429 GenerateLookupJoinsWithFilter (higher cost) 430 -------------------------------------------------------------------------------- 431 project 432 ├── columns: s:4 433 - └── inner-join (merge) 434 + └── inner-join (lookup a) 435 ├── columns: k:1!null i:2!null s:4 x:6!null 436 - ├── left ordering: +6 437 - ├── right ordering: +1 438 + ├── key columns: [6] = [1] 439 + ├── lookup columns are key 440 ├── key: (6) 441 ├── fd: ()-->(2), (1)-->(4), (1)==(6), (6)==(1) 442 ├── scan xy 443 │ ├── columns: x:6!null 444 - │ ├── key: (6) 445 - │ └── ordering: +6 446 - ├── select 447 - │ ├── columns: k:1!null i:2!null s:4 448 - │ ├── key: (1) 449 - │ ├── fd: ()-->(2), (1)-->(4) 450 - │ ├── ordering: +1 opt(2) [actual: +1] 451 - │ ├── scan a 452 - │ │ ├── columns: k:1!null i:2 s:4 453 - │ │ ├── key: (1) 454 - │ │ ├── fd: (1)-->(2,4) 455 - │ │ └── ordering: +1 opt(2) [actual: +1] 456 - │ └── filters 457 - │ └── i:2 = 9 [outer=(2), constraints=(/2: [/9 - /9]; tight), fd=()-->(2)] 458 - └── filters (true) 459 + │ └── key: (6) 460 + └── filters 461 + └── i:2 = 9 [outer=(2), constraints=(/2: [/9 - /9]; tight), fd=()-->(2)] 462 ================================================================================ 463 Final best expression 464 Cost: 1150.45 465 ================================================================================ 466 project 467 ├── columns: s:4 468 └── inner-join (lookup xy) 469 ├── columns: k:1!null i:2!null s:4 x:6!null 470 ├── key columns: [1] = [6] 471 ├── lookup columns are key 472 ├── key: (6) 473 ├── fd: ()-->(2), (1)-->(4), (1)==(6), (6)==(1) 474 ├── select 475 │ ├── columns: k:1!null i:2!null s:4 476 │ ├── key: (1) 477 │ ├── fd: ()-->(2), (1)-->(4) 478 │ ├── scan a 479 │ │ ├── columns: k:1!null i:2 s:4 480 │ │ ├── key: (1) 481 │ │ └── fd: (1)-->(2,4) 482 │ └── filters 483 │ └── i:2 = 9 [outer=(2), constraints=(/2: [/9 - /9]; tight), fd=()-->(2)] 484 └── filters (true) 485 486 # Exploration patterns with varying costs. 487 optsteps 488 SELECT s, k FROM a WHERE s='foo' AND f>100 489 ---- 490 ================================================================================ 491 Initial expression 492 Cost: 1110.13 493 ================================================================================ 494 project 495 ├── columns: s:4!null k:1!null 496 ├── key: (1) 497 ├── fd: ()-->(4) 498 └── select 499 ├── columns: k:1!null i:2 f:3!null s:4!null j:5 500 ├── key: (1) 501 ├── fd: ()-->(4), (1)-->(2,3,5), (3)-->(1,2,5) 502 ├── scan a 503 │ ├── columns: k:1!null i:2 f:3 s:4 j:5 504 │ ├── key: (1) 505 │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 506 └── filters 507 └── (s:4 = 'foo') AND (f:3 > 100.0) [outer=(3,4), constraints=(/3: [/100.00000000000001 - ]; /4: [/'foo' - /'foo']; tight), fd=()-->(4)] 508 ================================================================================ 509 SimplifySelectFilters 510 Cost: 1110.13 511 ================================================================================ 512 project 513 ├── columns: s:4!null k:1!null 514 ├── key: (1) 515 ├── fd: ()-->(4) 516 └── select 517 ├── columns: k:1!null i:2 f:3!null s:4!null j:5 518 ├── key: (1) 519 ├── fd: ()-->(4), (1)-->(2,3,5), (3)-->(1,2,5) 520 ├── scan a 521 │ ├── columns: k:1!null i:2 f:3 s:4 j:5 522 │ ├── key: (1) 523 │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 524 └── filters 525 - └── (s:4 = 'foo') AND (f:3 > 100.0) [outer=(3,4), constraints=(/3: [/100.00000000000001 - ]; /4: [/'foo' - /'foo']; tight), fd=()-->(4)] 526 + ├── s:4 = 'foo' [outer=(4), constraints=(/4: [/'foo' - /'foo']; tight), fd=()-->(4)] 527 + └── f:3 > 100.0 [outer=(3), constraints=(/3: [/100.00000000000001 - ]; tight)] 528 ================================================================================ 529 PruneSelectCols 530 Cost: 1090.13 531 ================================================================================ 532 project 533 ├── columns: s:4!null k:1!null 534 ├── key: (1) 535 ├── fd: ()-->(4) 536 └── select 537 - ├── columns: k:1!null i:2 f:3!null s:4!null j:5 538 + ├── columns: k:1!null f:3!null s:4!null 539 ├── key: (1) 540 - ├── fd: ()-->(4), (1)-->(2,3,5), (3)-->(1,2,5) 541 + ├── fd: ()-->(4), (1)-->(3), (3)-->(1) 542 ├── scan a 543 - │ ├── columns: k:1!null i:2 f:3 s:4 j:5 544 + │ ├── columns: k:1!null f:3 s:4 545 │ ├── key: (1) 546 - │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 547 + │ └── fd: (1)-->(3,4), (3,4)~~>(1) 548 └── filters 549 ├── s:4 = 'foo' [outer=(4), constraints=(/4: [/'foo' - /'foo']; tight), fd=()-->(4)] 550 └── f:3 > 100.0 [outer=(3), constraints=(/3: [/100.00000000000001 - ]; tight)] 551 ================================================================================ 552 GenerateIndexScans 553 Cost: 1080.13 554 ================================================================================ 555 project 556 ├── columns: s:4!null k:1!null 557 ├── key: (1) 558 ├── fd: ()-->(4) 559 └── select 560 ├── columns: k:1!null f:3!null s:4!null 561 ├── key: (1) 562 ├── fd: ()-->(4), (1)-->(3), (3)-->(1) 563 - ├── scan a 564 + ├── scan a@secondary 565 │ ├── columns: k:1!null f:3 s:4 566 │ ├── key: (1) 567 │ └── fd: (1)-->(3,4), (3,4)~~>(1) 568 └── filters 569 ├── s:4 = 'foo' [outer=(4), constraints=(/4: [/'foo' - /'foo']; tight), fd=()-->(4)] 570 └── f:3 > 100.0 [outer=(3), constraints=(/3: [/100.00000000000001 - ]; tight)] 571 -------------------------------------------------------------------------------- 572 GenerateZigzagJoins (no changes) 573 -------------------------------------------------------------------------------- 574 ================================================================================ 575 GenerateConstrainedScans 576 Cost: 10.10 577 ================================================================================ 578 project 579 ├── columns: s:4!null k:1!null 580 ├── key: (1) 581 ├── fd: ()-->(4) 582 - └── select 583 + └── scan a@secondary 584 ├── columns: k:1!null f:3!null s:4!null 585 + ├── constraint: /-4/3: [/'foo'/100.00000000000001 - /'foo'] 586 ├── key: (1) 587 - ├── fd: ()-->(4), (1)-->(3), (3)-->(1) 588 - ├── scan a@secondary 589 - │ ├── columns: k:1!null f:3 s:4 590 - │ ├── key: (1) 591 - │ └── fd: (1)-->(3,4), (3,4)~~>(1) 592 - └── filters 593 - ├── s:4 = 'foo' [outer=(4), constraints=(/4: [/'foo' - /'foo']; tight), fd=()-->(4)] 594 - └── f:3 > 100.0 [outer=(3), constraints=(/3: [/100.00000000000001 - ]; tight)] 595 + └── fd: ()-->(4), (1)-->(3), (3)-->(1) 596 ================================================================================ 597 Final best expression 598 Cost: 10.10 599 ================================================================================ 600 project 601 ├── columns: s:4!null k:1!null 602 ├── key: (1) 603 ├── fd: ()-->(4) 604 └── scan a@secondary 605 ├── columns: k:1!null f:3!null s:4!null 606 ├── constraint: /-4/3: [/'foo'/100.00000000000001 - /'foo'] 607 ├── key: (1) 608 └── fd: ()-->(4), (1)-->(3), (3)-->(1) 609 610 # Decorrelation pattern. 611 optsteps 612 SELECT * FROM a WHERE EXISTS(SELECT * FROM xy WHERE y=i) 613 ---- 614 ================================================================================ 615 Initial expression 616 Cost: 2160.06 617 ================================================================================ 618 select 619 ├── columns: k:1!null i:2 f:3 s:4 j:5 620 ├── key: (1) 621 ├── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 622 ├── scan a 623 │ ├── columns: k:1!null i:2 f:3 s:4 j:5 624 │ ├── key: (1) 625 │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 626 └── filters 627 └── exists [outer=(2), correlated-subquery] 628 └── select 629 ├── columns: x:6!null y:7!null 630 ├── outer: (2) 631 ├── key: (6) 632 ├── fd: ()-->(7) 633 ├── scan xy 634 │ ├── columns: x:6!null y:7 635 │ ├── key: (6) 636 │ └── fd: (6)-->(7) 637 └── filters 638 └── y:7 = i:2 [outer=(2,7), constraints=(/2: (/NULL - ]; /7: (/NULL - ]), fd=(2)==(7), (7)==(2)] 639 ================================================================================ 640 HoistSelectExists 641 Cost: 12089.90 642 ================================================================================ 643 select 644 ├── columns: k:1!null i:2 f:3 s:4 j:5 645 ├── key: (1) 646 ├── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 647 - ├── scan a 648 + ├── semi-join-apply 649 │ ├── columns: k:1!null i:2 f:3 s:4 j:5 650 │ ├── key: (1) 651 - │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 652 - └── filters 653 - └── exists [outer=(2), correlated-subquery] 654 - └── select 655 - ├── columns: x:6!null y:7!null 656 - ├── outer: (2) 657 - ├── key: (6) 658 - ├── fd: ()-->(7) 659 - ├── scan xy 660 - │ ├── columns: x:6!null y:7 661 - │ ├── key: (6) 662 - │ └── fd: (6)-->(7) 663 - └── filters 664 - └── y:7 = i:2 [outer=(2,7), constraints=(/2: (/NULL - ]; /7: (/NULL - ]), fd=(2)==(7), (7)==(2)] 665 + │ ├── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 666 + │ ├── scan a 667 + │ │ ├── columns: k:1!null i:2 f:3 s:4 j:5 668 + │ │ ├── key: (1) 669 + │ │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 670 + │ ├── select 671 + │ │ ├── columns: x:6!null y:7!null 672 + │ │ ├── outer: (2) 673 + │ │ ├── key: (6) 674 + │ │ ├── fd: ()-->(7) 675 + │ │ ├── scan xy 676 + │ │ │ ├── columns: x:6!null y:7 677 + │ │ │ ├── key: (6) 678 + │ │ │ └── fd: (6)-->(7) 679 + │ │ └── filters 680 + │ │ └── y:7 = i:2 [outer=(2,7), constraints=(/2: (/NULL - ]; /7: (/NULL - ]), fd=(2)==(7), (7)==(2)] 681 + │ └── filters (true) 682 + └── filters (true) 683 ================================================================================ 684 TryDecorrelateSelect 685 Cost: 2279.96 686 ================================================================================ 687 select 688 - ├── columns: k:1!null i:2 f:3 s:4 j:5 689 + ├── columns: k:1!null i:2!null f:3 s:4 j:5 690 ├── key: (1) 691 ├── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 692 ├── semi-join-apply 693 - │ ├── columns: k:1!null i:2 f:3 s:4 j:5 694 + │ ├── columns: k:1!null i:2!null f:3 s:4 j:5 695 │ ├── key: (1) 696 │ ├── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 697 │ ├── scan a 698 │ │ ├── columns: k:1!null i:2 f:3 s:4 j:5 699 │ │ ├── key: (1) 700 │ │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 701 - │ ├── select 702 - │ │ ├── columns: x:6!null y:7!null 703 - │ │ ├── outer: (2) 704 + │ ├── scan xy 705 + │ │ ├── columns: x:6!null y:7 706 │ │ ├── key: (6) 707 - │ │ ├── fd: ()-->(7) 708 - │ │ ├── scan xy 709 - │ │ │ ├── columns: x:6!null y:7 710 - │ │ │ ├── key: (6) 711 - │ │ │ └── fd: (6)-->(7) 712 - │ │ └── filters 713 - │ │ └── y:7 = i:2 [outer=(2,7), constraints=(/2: (/NULL - ]; /7: (/NULL - ]), fd=(2)==(7), (7)==(2)] 714 - │ └── filters (true) 715 + │ │ └── fd: (6)-->(7) 716 + │ └── filters 717 + │ └── y:7 = i:2 [outer=(2,7), constraints=(/2: (/NULL - ]; /7: (/NULL - ]), fd=(2)==(7), (7)==(2)] 718 └── filters (true) 719 ================================================================================ 720 DecorrelateJoin 721 Cost: 2278.07 722 ================================================================================ 723 select 724 - ├── columns: k:1!null i:2!null f:3 s:4 j:5 725 + ├── columns: k:1!null i:2 f:3 s:4 j:5 726 ├── key: (1) 727 ├── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 728 - ├── semi-join-apply 729 - │ ├── columns: k:1!null i:2!null f:3 s:4 j:5 730 + ├── semi-join (hash) 731 + │ ├── columns: k:1!null i:2 f:3 s:4 j:5 732 │ ├── key: (1) 733 │ ├── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 734 │ ├── scan a 735 │ │ ├── columns: k:1!null i:2 f:3 s:4 j:5 736 │ │ ├── key: (1) 737 │ │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 738 │ ├── scan xy 739 │ │ ├── columns: x:6!null y:7 740 │ │ ├── key: (6) 741 │ │ └── fd: (6)-->(7) 742 │ └── filters 743 │ └── y:7 = i:2 [outer=(2,7), constraints=(/2: (/NULL - ]; /7: (/NULL - ]), fd=(2)==(7), (7)==(2)] 744 └── filters (true) 745 ================================================================================ 746 PruneSemiAntiJoinRightCols 747 Cost: 2268.07 748 ================================================================================ 749 select 750 ├── columns: k:1!null i:2 f:3 s:4 j:5 751 ├── key: (1) 752 ├── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 753 ├── semi-join (hash) 754 │ ├── columns: k:1!null i:2 f:3 s:4 j:5 755 │ ├── key: (1) 756 │ ├── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 757 │ ├── scan a 758 │ │ ├── columns: k:1!null i:2 f:3 s:4 j:5 759 │ │ ├── key: (1) 760 │ │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 761 │ ├── scan xy 762 - │ │ ├── columns: x:6!null y:7 763 - │ │ ├── key: (6) 764 - │ │ └── fd: (6)-->(7) 765 + │ │ └── columns: y:7 766 │ └── filters 767 │ └── y:7 = i:2 [outer=(2,7), constraints=(/2: (/NULL - ]; /7: (/NULL - ]), fd=(2)==(7), (7)==(2)] 768 └── filters (true) 769 ================================================================================ 770 EliminateSelect 771 Cost: 2258.06 772 ================================================================================ 773 -select 774 +semi-join (hash) 775 ├── columns: k:1!null i:2 f:3 s:4 j:5 776 ├── key: (1) 777 ├── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 778 - ├── semi-join (hash) 779 + ├── scan a 780 │ ├── columns: k:1!null i:2 f:3 s:4 j:5 781 │ ├── key: (1) 782 - │ ├── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 783 - │ ├── scan a 784 - │ │ ├── columns: k:1!null i:2 f:3 s:4 j:5 785 - │ │ ├── key: (1) 786 - │ │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 787 - │ ├── scan xy 788 - │ │ └── columns: y:7 789 - │ └── filters 790 - │ └── y:7 = i:2 [outer=(2,7), constraints=(/2: (/NULL - ]; /7: (/NULL - ]), fd=(2)==(7), (7)==(2)] 791 - └── filters (true) 792 + │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 793 + ├── scan xy 794 + │ └── columns: y:7 795 + └── filters 796 + └── y:7 = i:2 [outer=(2,7), constraints=(/2: (/NULL - ]; /7: (/NULL - ]), fd=(2)==(7), (7)==(2)] 797 -------------------------------------------------------------------------------- 798 GenerateIndexScans (no changes) 799 -------------------------------------------------------------------------------- 800 -------------------------------------------------------------------------------- 801 GenerateIndexScans (no changes) 802 -------------------------------------------------------------------------------- 803 ================================================================================ 804 CommuteSemiJoin 805 Cost: 2185.13 806 ================================================================================ 807 -semi-join (hash) 808 +project 809 ├── columns: k:1!null i:2 f:3 s:4 j:5 810 ├── key: (1) 811 ├── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 812 - ├── scan a 813 - │ ├── columns: k:1!null i:2 f:3 s:4 j:5 814 - │ ├── key: (1) 815 - │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 816 - ├── scan xy 817 - │ └── columns: y:7 818 - └── filters 819 - └── y:7 = i:2 [outer=(2,7), constraints=(/2: (/NULL - ]; /7: (/NULL - ]), fd=(2)==(7), (7)==(2)] 820 + └── inner-join (hash) 821 + ├── columns: k:1!null i:2!null f:3 s:4 j:5 y:7!null 822 + ├── key: (1) 823 + ├── fd: (1)-->(2-5), (3,4)~~>(1,2,5), (2)==(7), (7)==(2) 824 + ├── scan a 825 + │ ├── columns: k:1!null i:2 f:3 s:4 j:5 826 + │ ├── key: (1) 827 + │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 828 + ├── distinct-on 829 + │ ├── columns: y:7 830 + │ ├── grouping columns: y:7 831 + │ ├── key: (7) 832 + │ └── scan xy 833 + │ └── columns: y:7 834 + └── filters 835 + └── y:7 = i:2 [outer=(2,7), constraints=(/2: (/NULL - ]; /7: (/NULL - ]), fd=(2)==(7), (7)==(2)] 836 -------------------------------------------------------------------------------- 837 GenerateMergeJoins (no changes) 838 -------------------------------------------------------------------------------- 839 -------------------------------------------------------------------------------- 840 GenerateLookupJoins (no changes) 841 -------------------------------------------------------------------------------- 842 -------------------------------------------------------------------------------- 843 GenerateStreamingGroupBy (no changes) 844 -------------------------------------------------------------------------------- 845 -------------------------------------------------------------------------------- 846 CommuteJoin (no changes) 847 -------------------------------------------------------------------------------- 848 -------------------------------------------------------------------------------- 849 GenerateMergeJoins (no changes) 850 -------------------------------------------------------------------------------- 851 -------------------------------------------------------------------------------- 852 CommuteJoin (no changes) 853 -------------------------------------------------------------------------------- 854 -------------------------------------------------------------------------------- 855 GenerateMergeJoins (no changes) 856 -------------------------------------------------------------------------------- 857 -------------------------------------------------------------------------------- 858 GenerateLookupJoins (no changes) 859 -------------------------------------------------------------------------------- 860 ================================================================================ 861 Final best expression 862 Cost: 2185.13 863 ================================================================================ 864 project 865 ├── columns: k:1!null i:2 f:3 s:4 j:5 866 ├── key: (1) 867 ├── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 868 └── inner-join (hash) 869 ├── columns: k:1!null i:2!null f:3 s:4 j:5 y:7!null 870 ├── key: (1) 871 ├── fd: (1)-->(2-5), (3,4)~~>(1,2,5), (2)==(7), (7)==(2) 872 ├── scan a 873 │ ├── columns: k:1!null i:2 f:3 s:4 j:5 874 │ ├── key: (1) 875 │ └── fd: (1)-->(2-5), (3,4)~~>(1,2,5) 876 ├── distinct-on 877 │ ├── columns: y:7 878 │ ├── grouping columns: y:7 879 │ ├── key: (7) 880 │ └── scan xy 881 │ └── columns: y:7 882 └── filters 883 └── y:7 = i:2 [outer=(2,7), constraints=(/2: (/NULL - ]; /7: (/NULL - ]), fd=(2)==(7), (7)==(2)] 884 885 # Decorrelation pattern using ANY function. 886 optsteps 887 SELECT 5=ANY(SELECT i FROM a WHERE k=x) AS r FROM xy 888 ---- 889 ================================================================================ 890 Initial expression 891 Cost: 2170.08 892 ================================================================================ 893 project 894 ├── columns: r:8 895 ├── scan xy 896 │ ├── columns: x:1!null y:2 897 │ ├── key: (1) 898 │ └── fd: (1)-->(2) 899 └── projections 900 └── any: eq [as=r:8, outer=(1), correlated-subquery] 901 ├── project 902 │ ├── columns: i:4 903 │ ├── outer: (1) 904 │ ├── cardinality: [0 - 1] 905 │ ├── key: () 906 │ ├── fd: ()-->(4) 907 │ └── select 908 │ ├── columns: k:3!null i:4 f:5 s:6 j:7 909 │ ├── outer: (1) 910 │ ├── cardinality: [0 - 1] 911 │ ├── key: () 912 │ ├── fd: ()-->(3-7) 913 │ ├── scan a 914 │ │ ├── columns: k:3!null i:4 f:5 s:6 j:7 915 │ │ ├── key: (3) 916 │ │ └── fd: (3)-->(4-7), (5,6)~~>(3,4,7) 917 │ └── filters 918 │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 919 └── 5 920 ================================================================================ 921 PruneSelectCols 922 Cost: 2140.08 923 ================================================================================ 924 project 925 ├── columns: r:8 926 ├── scan xy 927 │ ├── columns: x:1!null y:2 928 │ ├── key: (1) 929 │ └── fd: (1)-->(2) 930 └── projections 931 └── any: eq [as=r:8, outer=(1), correlated-subquery] 932 ├── project 933 │ ├── columns: i:4 934 │ ├── outer: (1) 935 │ ├── cardinality: [0 - 1] 936 │ ├── key: () 937 │ ├── fd: ()-->(4) 938 │ └── select 939 - │ ├── columns: k:3!null i:4 f:5 s:6 j:7 940 + │ ├── columns: k:3!null i:4 941 │ ├── outer: (1) 942 │ ├── cardinality: [0 - 1] 943 │ ├── key: () 944 - │ ├── fd: ()-->(3-7) 945 + │ ├── fd: ()-->(3,4) 946 │ ├── scan a 947 - │ │ ├── columns: k:3!null i:4 f:5 s:6 j:7 948 + │ │ ├── columns: k:3!null i:4 949 │ │ ├── key: (3) 950 - │ │ └── fd: (3)-->(4-7), (5,6)~~>(3,4,7) 951 + │ │ └── fd: (3)-->(4) 952 │ └── filters 953 │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 954 └── 5 955 ================================================================================ 956 PruneScanCols 957 Cost: 2130.08 958 ================================================================================ 959 project 960 ├── columns: r:8 961 ├── scan xy 962 - │ ├── columns: x:1!null y:2 963 - │ ├── key: (1) 964 - │ └── fd: (1)-->(2) 965 + │ ├── columns: x:1!null 966 + │ └── key: (1) 967 └── projections 968 └── any: eq [as=r:8, outer=(1), correlated-subquery] 969 ├── project 970 │ ├── columns: i:4 971 │ ├── outer: (1) 972 │ ├── cardinality: [0 - 1] 973 │ ├── key: () 974 │ ├── fd: ()-->(4) 975 │ └── select 976 │ ├── columns: k:3!null i:4 977 │ ├── outer: (1) 978 │ ├── cardinality: [0 - 1] 979 │ ├── key: () 980 │ ├── fd: ()-->(3,4) 981 │ ├── scan a 982 │ │ ├── columns: k:3!null i:4 983 │ │ ├── key: (3) 984 │ │ └── fd: (3)-->(4) 985 │ └── filters 986 │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 987 └── 5 988 ================================================================================ 989 HoistProjectSubquery 990 Cost: 2152.71 991 ================================================================================ 992 project 993 ├── columns: r:8 994 - ├── scan xy 995 - │ ├── columns: x:1!null 996 - │ └── key: (1) 997 + ├── inner-join-apply 998 + │ ├── columns: x:1!null case:11 999 + │ ├── key: (1) 1000 + │ ├── fd: (1)-->(11) 1001 + │ ├── scan xy 1002 + │ │ ├── columns: x:1!null 1003 + │ │ └── key: (1) 1004 + │ ├── project 1005 + │ │ ├── columns: case:11 1006 + │ │ ├── outer: (1) 1007 + │ │ ├── cardinality: [1 - 1] 1008 + │ │ ├── key: () 1009 + │ │ ├── fd: ()-->(11) 1010 + │ │ ├── scalar-group-by 1011 + │ │ │ ├── columns: bool_or:10 1012 + │ │ │ ├── outer: (1) 1013 + │ │ │ ├── cardinality: [1 - 1] 1014 + │ │ │ ├── key: () 1015 + │ │ │ ├── fd: ()-->(10) 1016 + │ │ │ ├── project 1017 + │ │ │ │ ├── columns: notnull:9!null 1018 + │ │ │ │ ├── outer: (1) 1019 + │ │ │ │ ├── cardinality: [0 - 1] 1020 + │ │ │ │ ├── key: () 1021 + │ │ │ │ ├── fd: ()-->(9) 1022 + │ │ │ │ ├── select 1023 + │ │ │ │ │ ├── columns: i:4 1024 + │ │ │ │ │ ├── outer: (1) 1025 + │ │ │ │ │ ├── cardinality: [0 - 1] 1026 + │ │ │ │ │ ├── key: () 1027 + │ │ │ │ │ ├── fd: ()-->(4) 1028 + │ │ │ │ │ ├── project 1029 + │ │ │ │ │ │ ├── columns: i:4 1030 + │ │ │ │ │ │ ├── outer: (1) 1031 + │ │ │ │ │ │ ├── cardinality: [0 - 1] 1032 + │ │ │ │ │ │ ├── key: () 1033 + │ │ │ │ │ │ ├── fd: ()-->(4) 1034 + │ │ │ │ │ │ └── select 1035 + │ │ │ │ │ │ ├── columns: k:3!null i:4 1036 + │ │ │ │ │ │ ├── outer: (1) 1037 + │ │ │ │ │ │ ├── cardinality: [0 - 1] 1038 + │ │ │ │ │ │ ├── key: () 1039 + │ │ │ │ │ │ ├── fd: ()-->(3,4) 1040 + │ │ │ │ │ │ ├── scan a 1041 + │ │ │ │ │ │ │ ├── columns: k:3!null i:4 1042 + │ │ │ │ │ │ │ ├── key: (3) 1043 + │ │ │ │ │ │ │ └── fd: (3)-->(4) 1044 + │ │ │ │ │ │ └── filters 1045 + │ │ │ │ │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1046 + │ │ │ │ │ └── filters 1047 + │ │ │ │ │ └── (5 = i:4) IS NOT false [outer=(4)] 1048 + │ │ │ │ └── projections 1049 + │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 1050 + │ │ │ └── aggregations 1051 + │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 1052 + │ │ │ └── notnull:9 1053 + │ │ └── projections 1054 + │ │ └── CASE WHEN bool_or:10 AND (5 IS NOT NULL) THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 1055 + │ └── filters (true) 1056 └── projections 1057 - └── any: eq [as=r:8, outer=(1), correlated-subquery] 1058 - ├── project 1059 - │ ├── columns: i:4 1060 - │ ├── outer: (1) 1061 - │ ├── cardinality: [0 - 1] 1062 - │ ├── key: () 1063 - │ ├── fd: ()-->(4) 1064 - │ └── select 1065 - │ ├── columns: k:3!null i:4 1066 - │ ├── outer: (1) 1067 - │ ├── cardinality: [0 - 1] 1068 - │ ├── key: () 1069 - │ ├── fd: ()-->(3,4) 1070 - │ ├── scan a 1071 - │ │ ├── columns: k:3!null i:4 1072 - │ │ ├── key: (3) 1073 - │ │ └── fd: (3)-->(4) 1074 - │ └── filters 1075 - │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1076 - └── 5 1077 + └── case:11 [as=r:8, outer=(11)] 1078 ================================================================================ 1079 CommuteVar 1080 Cost: 2152.71 1081 ================================================================================ 1082 project 1083 ├── columns: r:8 1084 ├── inner-join-apply 1085 │ ├── columns: x:1!null case:11 1086 │ ├── key: (1) 1087 │ ├── fd: (1)-->(11) 1088 │ ├── scan xy 1089 │ │ ├── columns: x:1!null 1090 │ │ └── key: (1) 1091 │ ├── project 1092 │ │ ├── columns: case:11 1093 │ │ ├── outer: (1) 1094 │ │ ├── cardinality: [1 - 1] 1095 │ │ ├── key: () 1096 │ │ ├── fd: ()-->(11) 1097 │ │ ├── scalar-group-by 1098 │ │ │ ├── columns: bool_or:10 1099 │ │ │ ├── outer: (1) 1100 │ │ │ ├── cardinality: [1 - 1] 1101 │ │ │ ├── key: () 1102 │ │ │ ├── fd: ()-->(10) 1103 │ │ │ ├── project 1104 │ │ │ │ ├── columns: notnull:9!null 1105 │ │ │ │ ├── outer: (1) 1106 │ │ │ │ ├── cardinality: [0 - 1] 1107 │ │ │ │ ├── key: () 1108 │ │ │ │ ├── fd: ()-->(9) 1109 │ │ │ │ ├── select 1110 │ │ │ │ │ ├── columns: i:4 1111 │ │ │ │ │ ├── outer: (1) 1112 │ │ │ │ │ ├── cardinality: [0 - 1] 1113 │ │ │ │ │ ├── key: () 1114 │ │ │ │ │ ├── fd: ()-->(4) 1115 │ │ │ │ │ ├── project 1116 │ │ │ │ │ │ ├── columns: i:4 1117 │ │ │ │ │ │ ├── outer: (1) 1118 │ │ │ │ │ │ ├── cardinality: [0 - 1] 1119 │ │ │ │ │ │ ├── key: () 1120 │ │ │ │ │ │ ├── fd: ()-->(4) 1121 │ │ │ │ │ │ └── select 1122 │ │ │ │ │ │ ├── columns: k:3!null i:4 1123 │ │ │ │ │ │ ├── outer: (1) 1124 │ │ │ │ │ │ ├── cardinality: [0 - 1] 1125 │ │ │ │ │ │ ├── key: () 1126 │ │ │ │ │ │ ├── fd: ()-->(3,4) 1127 │ │ │ │ │ │ ├── scan a 1128 │ │ │ │ │ │ │ ├── columns: k:3!null i:4 1129 │ │ │ │ │ │ │ ├── key: (3) 1130 │ │ │ │ │ │ │ └── fd: (3)-->(4) 1131 │ │ │ │ │ │ └── filters 1132 │ │ │ │ │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1133 │ │ │ │ │ └── filters 1134 - │ │ │ │ │ └── (5 = i:4) IS NOT false [outer=(4)] 1135 + │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 1136 │ │ │ │ └── projections 1137 │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 1138 │ │ │ └── aggregations 1139 │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 1140 │ │ │ └── notnull:9 1141 │ │ └── projections 1142 │ │ └── CASE WHEN bool_or:10 AND (5 IS NOT NULL) THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 1143 │ └── filters (true) 1144 └── projections 1145 └── case:11 [as=r:8, outer=(11)] 1146 ================================================================================ 1147 PushSelectIntoProject 1148 Cost: 2152.71 1149 ================================================================================ 1150 project 1151 ├── columns: r:8 1152 ├── inner-join-apply 1153 │ ├── columns: x:1!null case:11 1154 │ ├── key: (1) 1155 │ ├── fd: (1)-->(11) 1156 │ ├── scan xy 1157 │ │ ├── columns: x:1!null 1158 │ │ └── key: (1) 1159 │ ├── project 1160 │ │ ├── columns: case:11 1161 │ │ ├── outer: (1) 1162 │ │ ├── cardinality: [1 - 1] 1163 │ │ ├── key: () 1164 │ │ ├── fd: ()-->(11) 1165 │ │ ├── scalar-group-by 1166 │ │ │ ├── columns: bool_or:10 1167 │ │ │ ├── outer: (1) 1168 │ │ │ ├── cardinality: [1 - 1] 1169 │ │ │ ├── key: () 1170 │ │ │ ├── fd: ()-->(10) 1171 │ │ │ ├── project 1172 │ │ │ │ ├── columns: notnull:9!null 1173 │ │ │ │ ├── outer: (1) 1174 │ │ │ │ ├── cardinality: [0 - 1] 1175 │ │ │ │ ├── key: () 1176 │ │ │ │ ├── fd: ()-->(9) 1177 │ │ │ │ ├── select 1178 │ │ │ │ │ ├── columns: i:4 1179 │ │ │ │ │ ├── outer: (1) 1180 │ │ │ │ │ ├── cardinality: [0 - 1] 1181 │ │ │ │ │ ├── key: () 1182 │ │ │ │ │ ├── fd: ()-->(4) 1183 │ │ │ │ │ ├── project 1184 │ │ │ │ │ │ ├── columns: i:4 1185 │ │ │ │ │ │ ├── outer: (1) 1186 │ │ │ │ │ │ ├── cardinality: [0 - 1] 1187 │ │ │ │ │ │ ├── key: () 1188 │ │ │ │ │ │ ├── fd: ()-->(4) 1189 │ │ │ │ │ │ └── select 1190 │ │ │ │ │ │ ├── columns: k:3!null i:4 1191 │ │ │ │ │ │ ├── outer: (1) 1192 │ │ │ │ │ │ ├── cardinality: [0 - 1] 1193 │ │ │ │ │ │ ├── key: () 1194 │ │ │ │ │ │ ├── fd: ()-->(3,4) 1195 - │ │ │ │ │ │ ├── scan a 1196 + │ │ │ │ │ │ ├── select 1197 │ │ │ │ │ │ │ ├── columns: k:3!null i:4 1198 - │ │ │ │ │ │ │ ├── key: (3) 1199 - │ │ │ │ │ │ │ └── fd: (3)-->(4) 1200 + │ │ │ │ │ │ │ ├── outer: (1) 1201 + │ │ │ │ │ │ │ ├── cardinality: [0 - 1] 1202 + │ │ │ │ │ │ │ ├── key: () 1203 + │ │ │ │ │ │ │ ├── fd: ()-->(3,4) 1204 + │ │ │ │ │ │ │ ├── scan a 1205 + │ │ │ │ │ │ │ │ ├── columns: k:3!null i:4 1206 + │ │ │ │ │ │ │ │ ├── key: (3) 1207 + │ │ │ │ │ │ │ │ └── fd: (3)-->(4) 1208 + │ │ │ │ │ │ │ └── filters 1209 + │ │ │ │ │ │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1210 │ │ │ │ │ │ └── filters 1211 - │ │ │ │ │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1212 - │ │ │ │ │ └── filters 1213 - │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 1214 + │ │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 1215 + │ │ │ │ │ └── filters (true) 1216 │ │ │ │ └── projections 1217 │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 1218 │ │ │ └── aggregations 1219 │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 1220 │ │ │ └── notnull:9 1221 │ │ └── projections 1222 │ │ └── CASE WHEN bool_or:10 AND (5 IS NOT NULL) THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 1223 │ └── filters (true) 1224 └── projections 1225 └── case:11 [as=r:8, outer=(11)] 1226 ================================================================================ 1227 MergeSelects 1228 Cost: 2152.73 1229 ================================================================================ 1230 project 1231 ├── columns: r:8 1232 ├── inner-join-apply 1233 │ ├── columns: x:1!null case:11 1234 │ ├── key: (1) 1235 │ ├── fd: (1)-->(11) 1236 │ ├── scan xy 1237 │ │ ├── columns: x:1!null 1238 │ │ └── key: (1) 1239 │ ├── project 1240 │ │ ├── columns: case:11 1241 │ │ ├── outer: (1) 1242 │ │ ├── cardinality: [1 - 1] 1243 │ │ ├── key: () 1244 │ │ ├── fd: ()-->(11) 1245 │ │ ├── scalar-group-by 1246 │ │ │ ├── columns: bool_or:10 1247 │ │ │ ├── outer: (1) 1248 │ │ │ ├── cardinality: [1 - 1] 1249 │ │ │ ├── key: () 1250 │ │ │ ├── fd: ()-->(10) 1251 │ │ │ ├── project 1252 │ │ │ │ ├── columns: notnull:9!null 1253 │ │ │ │ ├── outer: (1) 1254 │ │ │ │ ├── cardinality: [0 - 1] 1255 │ │ │ │ ├── key: () 1256 │ │ │ │ ├── fd: ()-->(9) 1257 │ │ │ │ ├── select 1258 │ │ │ │ │ ├── columns: i:4 1259 │ │ │ │ │ ├── outer: (1) 1260 │ │ │ │ │ ├── cardinality: [0 - 1] 1261 │ │ │ │ │ ├── key: () 1262 │ │ │ │ │ ├── fd: ()-->(4) 1263 │ │ │ │ │ ├── project 1264 │ │ │ │ │ │ ├── columns: i:4 1265 │ │ │ │ │ │ ├── outer: (1) 1266 │ │ │ │ │ │ ├── cardinality: [0 - 1] 1267 │ │ │ │ │ │ ├── key: () 1268 │ │ │ │ │ │ ├── fd: ()-->(4) 1269 │ │ │ │ │ │ └── select 1270 │ │ │ │ │ │ ├── columns: k:3!null i:4 1271 │ │ │ │ │ │ ├── outer: (1) 1272 │ │ │ │ │ │ ├── cardinality: [0 - 1] 1273 │ │ │ │ │ │ ├── key: () 1274 │ │ │ │ │ │ ├── fd: ()-->(3,4) 1275 - │ │ │ │ │ │ ├── select 1276 + │ │ │ │ │ │ ├── scan a 1277 │ │ │ │ │ │ │ ├── columns: k:3!null i:4 1278 - │ │ │ │ │ │ │ ├── outer: (1) 1279 - │ │ │ │ │ │ │ ├── cardinality: [0 - 1] 1280 - │ │ │ │ │ │ │ ├── key: () 1281 - │ │ │ │ │ │ │ ├── fd: ()-->(3,4) 1282 - │ │ │ │ │ │ │ ├── scan a 1283 - │ │ │ │ │ │ │ │ ├── columns: k:3!null i:4 1284 - │ │ │ │ │ │ │ │ ├── key: (3) 1285 - │ │ │ │ │ │ │ │ └── fd: (3)-->(4) 1286 - │ │ │ │ │ │ │ └── filters 1287 - │ │ │ │ │ │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1288 + │ │ │ │ │ │ │ ├── key: (3) 1289 + │ │ │ │ │ │ │ └── fd: (3)-->(4) 1290 │ │ │ │ │ │ └── filters 1291 + │ │ │ │ │ │ ├── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1292 │ │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 1293 │ │ │ │ │ └── filters (true) 1294 │ │ │ │ └── projections 1295 │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 1296 │ │ │ └── aggregations 1297 │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 1298 │ │ │ └── notnull:9 1299 │ │ └── projections 1300 │ │ └── CASE WHEN bool_or:10 AND (5 IS NOT NULL) THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 1301 │ └── filters (true) 1302 └── projections 1303 └── case:11 [as=r:8, outer=(11)] 1304 ================================================================================ 1305 EliminateSelect 1306 Cost: 2152.71 1307 ================================================================================ 1308 project 1309 ├── columns: r:8 1310 ├── inner-join-apply 1311 │ ├── columns: x:1!null case:11 1312 │ ├── key: (1) 1313 │ ├── fd: (1)-->(11) 1314 │ ├── scan xy 1315 │ │ ├── columns: x:1!null 1316 │ │ └── key: (1) 1317 │ ├── project 1318 │ │ ├── columns: case:11 1319 │ │ ├── outer: (1) 1320 │ │ ├── cardinality: [1 - 1] 1321 │ │ ├── key: () 1322 │ │ ├── fd: ()-->(11) 1323 │ │ ├── scalar-group-by 1324 │ │ │ ├── columns: bool_or:10 1325 │ │ │ ├── outer: (1) 1326 │ │ │ ├── cardinality: [1 - 1] 1327 │ │ │ ├── key: () 1328 │ │ │ ├── fd: ()-->(10) 1329 │ │ │ ├── project 1330 │ │ │ │ ├── columns: notnull:9!null 1331 │ │ │ │ ├── outer: (1) 1332 │ │ │ │ ├── cardinality: [0 - 1] 1333 │ │ │ │ ├── key: () 1334 │ │ │ │ ├── fd: ()-->(9) 1335 - │ │ │ │ ├── select 1336 + │ │ │ │ ├── project 1337 │ │ │ │ │ ├── columns: i:4 1338 │ │ │ │ │ ├── outer: (1) 1339 │ │ │ │ │ ├── cardinality: [0 - 1] 1340 │ │ │ │ │ ├── key: () 1341 │ │ │ │ │ ├── fd: ()-->(4) 1342 - │ │ │ │ │ ├── project 1343 - │ │ │ │ │ │ ├── columns: i:4 1344 - │ │ │ │ │ │ ├── outer: (1) 1345 - │ │ │ │ │ │ ├── cardinality: [0 - 1] 1346 - │ │ │ │ │ │ ├── key: () 1347 - │ │ │ │ │ │ ├── fd: ()-->(4) 1348 - │ │ │ │ │ │ └── select 1349 - │ │ │ │ │ │ ├── columns: k:3!null i:4 1350 - │ │ │ │ │ │ ├── outer: (1) 1351 - │ │ │ │ │ │ ├── cardinality: [0 - 1] 1352 - │ │ │ │ │ │ ├── key: () 1353 - │ │ │ │ │ │ ├── fd: ()-->(3,4) 1354 - │ │ │ │ │ │ ├── scan a 1355 - │ │ │ │ │ │ │ ├── columns: k:3!null i:4 1356 - │ │ │ │ │ │ │ ├── key: (3) 1357 - │ │ │ │ │ │ │ └── fd: (3)-->(4) 1358 - │ │ │ │ │ │ └── filters 1359 - │ │ │ │ │ │ ├── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1360 - │ │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 1361 - │ │ │ │ │ └── filters (true) 1362 + │ │ │ │ │ └── select 1363 + │ │ │ │ │ ├── columns: k:3!null i:4 1364 + │ │ │ │ │ ├── outer: (1) 1365 + │ │ │ │ │ ├── cardinality: [0 - 1] 1366 + │ │ │ │ │ ├── key: () 1367 + │ │ │ │ │ ├── fd: ()-->(3,4) 1368 + │ │ │ │ │ ├── scan a 1369 + │ │ │ │ │ │ ├── columns: k:3!null i:4 1370 + │ │ │ │ │ │ ├── key: (3) 1371 + │ │ │ │ │ │ └── fd: (3)-->(4) 1372 + │ │ │ │ │ └── filters 1373 + │ │ │ │ │ ├── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1374 + │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 1375 │ │ │ │ └── projections 1376 │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 1377 │ │ │ └── aggregations 1378 │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 1379 │ │ │ └── notnull:9 1380 │ │ └── projections 1381 │ │ └── CASE WHEN bool_or:10 AND (5 IS NOT NULL) THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 1382 │ └── filters (true) 1383 └── projections 1384 └── case:11 [as=r:8, outer=(11)] 1385 ================================================================================ 1386 MergeProjects 1387 Cost: 2152.69 1388 ================================================================================ 1389 project 1390 ├── columns: r:8 1391 ├── inner-join-apply 1392 │ ├── columns: x:1!null case:11 1393 │ ├── key: (1) 1394 │ ├── fd: (1)-->(11) 1395 │ ├── scan xy 1396 │ │ ├── columns: x:1!null 1397 │ │ └── key: (1) 1398 │ ├── project 1399 │ │ ├── columns: case:11 1400 │ │ ├── outer: (1) 1401 │ │ ├── cardinality: [1 - 1] 1402 │ │ ├── key: () 1403 │ │ ├── fd: ()-->(11) 1404 │ │ ├── scalar-group-by 1405 │ │ │ ├── columns: bool_or:10 1406 │ │ │ ├── outer: (1) 1407 │ │ │ ├── cardinality: [1 - 1] 1408 │ │ │ ├── key: () 1409 │ │ │ ├── fd: ()-->(10) 1410 │ │ │ ├── project 1411 │ │ │ │ ├── columns: notnull:9!null 1412 │ │ │ │ ├── outer: (1) 1413 │ │ │ │ ├── cardinality: [0 - 1] 1414 │ │ │ │ ├── key: () 1415 │ │ │ │ ├── fd: ()-->(9) 1416 - │ │ │ │ ├── project 1417 - │ │ │ │ │ ├── columns: i:4 1418 + │ │ │ │ ├── select 1419 + │ │ │ │ │ ├── columns: k:3!null i:4 1420 │ │ │ │ │ ├── outer: (1) 1421 │ │ │ │ │ ├── cardinality: [0 - 1] 1422 │ │ │ │ │ ├── key: () 1423 - │ │ │ │ │ ├── fd: ()-->(4) 1424 - │ │ │ │ │ └── select 1425 - │ │ │ │ │ ├── columns: k:3!null i:4 1426 - │ │ │ │ │ ├── outer: (1) 1427 - │ │ │ │ │ ├── cardinality: [0 - 1] 1428 - │ │ │ │ │ ├── key: () 1429 - │ │ │ │ │ ├── fd: ()-->(3,4) 1430 - │ │ │ │ │ ├── scan a 1431 - │ │ │ │ │ │ ├── columns: k:3!null i:4 1432 - │ │ │ │ │ │ ├── key: (3) 1433 - │ │ │ │ │ │ └── fd: (3)-->(4) 1434 - │ │ │ │ │ └── filters 1435 - │ │ │ │ │ ├── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1436 - │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 1437 + │ │ │ │ │ ├── fd: ()-->(3,4) 1438 + │ │ │ │ │ ├── scan a 1439 + │ │ │ │ │ │ ├── columns: k:3!null i:4 1440 + │ │ │ │ │ │ ├── key: (3) 1441 + │ │ │ │ │ │ └── fd: (3)-->(4) 1442 + │ │ │ │ │ └── filters 1443 + │ │ │ │ │ ├── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1444 + │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 1445 │ │ │ │ └── projections 1446 │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 1447 │ │ │ └── aggregations 1448 │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 1449 │ │ │ └── notnull:9 1450 │ │ └── projections 1451 │ │ └── CASE WHEN bool_or:10 AND (5 IS NOT NULL) THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 1452 │ └── filters (true) 1453 └── projections 1454 └── case:11 [as=r:8, outer=(11)] 1455 ================================================================================ 1456 FoldNonNullIsNotNull 1457 Cost: 2152.69 1458 ================================================================================ 1459 project 1460 ├── columns: r:8 1461 ├── inner-join-apply 1462 │ ├── columns: x:1!null case:11 1463 │ ├── key: (1) 1464 │ ├── fd: (1)-->(11) 1465 │ ├── scan xy 1466 │ │ ├── columns: x:1!null 1467 │ │ └── key: (1) 1468 │ ├── project 1469 │ │ ├── columns: case:11 1470 │ │ ├── outer: (1) 1471 │ │ ├── cardinality: [1 - 1] 1472 │ │ ├── key: () 1473 │ │ ├── fd: ()-->(11) 1474 │ │ ├── scalar-group-by 1475 │ │ │ ├── columns: bool_or:10 1476 │ │ │ ├── outer: (1) 1477 │ │ │ ├── cardinality: [1 - 1] 1478 │ │ │ ├── key: () 1479 │ │ │ ├── fd: ()-->(10) 1480 │ │ │ ├── project 1481 │ │ │ │ ├── columns: notnull:9!null 1482 │ │ │ │ ├── outer: (1) 1483 │ │ │ │ ├── cardinality: [0 - 1] 1484 │ │ │ │ ├── key: () 1485 │ │ │ │ ├── fd: ()-->(9) 1486 │ │ │ │ ├── select 1487 │ │ │ │ │ ├── columns: k:3!null i:4 1488 │ │ │ │ │ ├── outer: (1) 1489 │ │ │ │ │ ├── cardinality: [0 - 1] 1490 │ │ │ │ │ ├── key: () 1491 │ │ │ │ │ ├── fd: ()-->(3,4) 1492 │ │ │ │ │ ├── scan a 1493 │ │ │ │ │ │ ├── columns: k:3!null i:4 1494 │ │ │ │ │ │ ├── key: (3) 1495 │ │ │ │ │ │ └── fd: (3)-->(4) 1496 │ │ │ │ │ └── filters 1497 │ │ │ │ │ ├── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1498 │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 1499 │ │ │ │ └── projections 1500 │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 1501 │ │ │ └── aggregations 1502 │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 1503 │ │ │ └── notnull:9 1504 │ │ └── projections 1505 - │ │ └── CASE WHEN bool_or:10 AND (5 IS NOT NULL) THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 1506 + │ │ └── CASE WHEN bool_or:10 AND true THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 1507 │ └── filters (true) 1508 └── projections 1509 └── case:11 [as=r:8, outer=(11)] 1510 ================================================================================ 1511 SimplifyAndTrue 1512 Cost: 2152.69 1513 ================================================================================ 1514 project 1515 ├── columns: r:8 1516 ├── inner-join-apply 1517 │ ├── columns: x:1!null case:11 1518 │ ├── key: (1) 1519 │ ├── fd: (1)-->(11) 1520 │ ├── scan xy 1521 │ │ ├── columns: x:1!null 1522 │ │ └── key: (1) 1523 │ ├── project 1524 │ │ ├── columns: case:11 1525 │ │ ├── outer: (1) 1526 │ │ ├── cardinality: [1 - 1] 1527 │ │ ├── key: () 1528 │ │ ├── fd: ()-->(11) 1529 │ │ ├── scalar-group-by 1530 │ │ │ ├── columns: bool_or:10 1531 │ │ │ ├── outer: (1) 1532 │ │ │ ├── cardinality: [1 - 1] 1533 │ │ │ ├── key: () 1534 │ │ │ ├── fd: ()-->(10) 1535 │ │ │ ├── project 1536 │ │ │ │ ├── columns: notnull:9!null 1537 │ │ │ │ ├── outer: (1) 1538 │ │ │ │ ├── cardinality: [0 - 1] 1539 │ │ │ │ ├── key: () 1540 │ │ │ │ ├── fd: ()-->(9) 1541 │ │ │ │ ├── select 1542 │ │ │ │ │ ├── columns: k:3!null i:4 1543 │ │ │ │ │ ├── outer: (1) 1544 │ │ │ │ │ ├── cardinality: [0 - 1] 1545 │ │ │ │ │ ├── key: () 1546 │ │ │ │ │ ├── fd: ()-->(3,4) 1547 │ │ │ │ │ ├── scan a 1548 │ │ │ │ │ │ ├── columns: k:3!null i:4 1549 │ │ │ │ │ │ ├── key: (3) 1550 │ │ │ │ │ │ └── fd: (3)-->(4) 1551 │ │ │ │ │ └── filters 1552 │ │ │ │ │ ├── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1553 │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 1554 │ │ │ │ └── projections 1555 │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 1556 │ │ │ └── aggregations 1557 │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 1558 │ │ │ └── notnull:9 1559 │ │ └── projections 1560 - │ │ └── CASE WHEN bool_or:10 AND true THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 1561 + │ │ └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 1562 │ └── filters (true) 1563 └── projections 1564 └── case:11 [as=r:8, outer=(11)] 1565 ================================================================================ 1566 TryDecorrelateProject 1567 Cost: 2182.68 1568 ================================================================================ 1569 project 1570 ├── columns: r:8 1571 - ├── inner-join-apply 1572 + ├── select 1573 │ ├── columns: x:1!null case:11 1574 │ ├── key: (1) 1575 │ ├── fd: (1)-->(11) 1576 - │ ├── scan xy 1577 - │ │ ├── columns: x:1!null 1578 - │ │ └── key: (1) 1579 │ ├── project 1580 - │ │ ├── columns: case:11 1581 - │ │ ├── outer: (1) 1582 - │ │ ├── cardinality: [1 - 1] 1583 - │ │ ├── key: () 1584 - │ │ ├── fd: ()-->(11) 1585 - │ │ ├── scalar-group-by 1586 - │ │ │ ├── columns: bool_or:10 1587 - │ │ │ ├── outer: (1) 1588 - │ │ │ ├── cardinality: [1 - 1] 1589 - │ │ │ ├── key: () 1590 - │ │ │ ├── fd: ()-->(10) 1591 - │ │ │ ├── project 1592 - │ │ │ │ ├── columns: notnull:9!null 1593 + │ │ ├── columns: case:11 x:1!null 1594 + │ │ ├── key: (1) 1595 + │ │ ├── fd: (1)-->(11) 1596 + │ │ ├── inner-join-apply 1597 + │ │ │ ├── columns: x:1!null bool_or:10 1598 + │ │ │ ├── key: (1) 1599 + │ │ │ ├── fd: (1)-->(10) 1600 + │ │ │ ├── scan xy 1601 + │ │ │ │ ├── columns: x:1!null 1602 + │ │ │ │ └── key: (1) 1603 + │ │ │ ├── scalar-group-by 1604 + │ │ │ │ ├── columns: bool_or:10 1605 │ │ │ │ ├── outer: (1) 1606 - │ │ │ │ ├── cardinality: [0 - 1] 1607 + │ │ │ │ ├── cardinality: [1 - 1] 1608 │ │ │ │ ├── key: () 1609 - │ │ │ │ ├── fd: ()-->(9) 1610 - │ │ │ │ ├── select 1611 - │ │ │ │ │ ├── columns: k:3!null i:4 1612 + │ │ │ │ ├── fd: ()-->(10) 1613 + │ │ │ │ ├── project 1614 + │ │ │ │ │ ├── columns: notnull:9!null 1615 │ │ │ │ │ ├── outer: (1) 1616 │ │ │ │ │ ├── cardinality: [0 - 1] 1617 │ │ │ │ │ ├── key: () 1618 - │ │ │ │ │ ├── fd: ()-->(3,4) 1619 - │ │ │ │ │ ├── scan a 1620 + │ │ │ │ │ ├── fd: ()-->(9) 1621 + │ │ │ │ │ ├── select 1622 │ │ │ │ │ │ ├── columns: k:3!null i:4 1623 - │ │ │ │ │ │ ├── key: (3) 1624 - │ │ │ │ │ │ └── fd: (3)-->(4) 1625 - │ │ │ │ │ └── filters 1626 - │ │ │ │ │ ├── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1627 - │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 1628 - │ │ │ │ └── projections 1629 - │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 1630 - │ │ │ └── aggregations 1631 - │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 1632 - │ │ │ └── notnull:9 1633 + │ │ │ │ │ │ ├── outer: (1) 1634 + │ │ │ │ │ │ ├── cardinality: [0 - 1] 1635 + │ │ │ │ │ │ ├── key: () 1636 + │ │ │ │ │ │ ├── fd: ()-->(3,4) 1637 + │ │ │ │ │ │ ├── scan a 1638 + │ │ │ │ │ │ │ ├── columns: k:3!null i:4 1639 + │ │ │ │ │ │ │ ├── key: (3) 1640 + │ │ │ │ │ │ │ └── fd: (3)-->(4) 1641 + │ │ │ │ │ │ └── filters 1642 + │ │ │ │ │ │ ├── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1643 + │ │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 1644 + │ │ │ │ │ └── projections 1645 + │ │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 1646 + │ │ │ │ └── aggregations 1647 + │ │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 1648 + │ │ │ │ └── notnull:9 1649 + │ │ │ └── filters (true) 1650 │ │ └── projections 1651 │ │ └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 1652 │ └── filters (true) 1653 └── projections 1654 └── case:11 [as=r:8, outer=(11)] 1655 ================================================================================ 1656 TryDecorrelateScalarGroupBy 1657 Cost: 2242.68 1658 ================================================================================ 1659 project 1660 ├── columns: r:8 1661 ├── select 1662 │ ├── columns: x:1!null case:11 1663 │ ├── key: (1) 1664 │ ├── fd: (1)-->(11) 1665 │ ├── project 1666 │ │ ├── columns: case:11 x:1!null 1667 │ │ ├── key: (1) 1668 │ │ ├── fd: (1)-->(11) 1669 - │ │ ├── inner-join-apply 1670 + │ │ ├── select 1671 │ │ │ ├── columns: x:1!null bool_or:10 1672 │ │ │ ├── key: (1) 1673 │ │ │ ├── fd: (1)-->(10) 1674 - │ │ │ ├── scan xy 1675 - │ │ │ │ ├── columns: x:1!null 1676 - │ │ │ │ └── key: (1) 1677 - │ │ │ ├── scalar-group-by 1678 - │ │ │ │ ├── columns: bool_or:10 1679 - │ │ │ │ ├── outer: (1) 1680 - │ │ │ │ ├── cardinality: [1 - 1] 1681 - │ │ │ │ ├── key: () 1682 - │ │ │ │ ├── fd: ()-->(10) 1683 - │ │ │ │ ├── project 1684 - │ │ │ │ │ ├── columns: notnull:9!null 1685 - │ │ │ │ │ ├── outer: (1) 1686 - │ │ │ │ │ ├── cardinality: [0 - 1] 1687 - │ │ │ │ │ ├── key: () 1688 - │ │ │ │ │ ├── fd: ()-->(9) 1689 - │ │ │ │ │ ├── select 1690 - │ │ │ │ │ │ ├── columns: k:3!null i:4 1691 - │ │ │ │ │ │ ├── outer: (1) 1692 - │ │ │ │ │ │ ├── cardinality: [0 - 1] 1693 - │ │ │ │ │ │ ├── key: () 1694 - │ │ │ │ │ │ ├── fd: ()-->(3,4) 1695 - │ │ │ │ │ │ ├── scan a 1696 - │ │ │ │ │ │ │ ├── columns: k:3!null i:4 1697 - │ │ │ │ │ │ │ ├── key: (3) 1698 - │ │ │ │ │ │ │ └── fd: (3)-->(4) 1699 - │ │ │ │ │ │ └── filters 1700 - │ │ │ │ │ │ ├── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1701 - │ │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 1702 - │ │ │ │ │ └── projections 1703 - │ │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 1704 - │ │ │ │ └── aggregations 1705 - │ │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 1706 - │ │ │ │ └── notnull:9 1707 + │ │ │ ├── project 1708 + │ │ │ │ ├── columns: x:1!null bool_or:10 1709 + │ │ │ │ ├── key: (1) 1710 + │ │ │ │ ├── fd: (1)-->(10) 1711 + │ │ │ │ └── group-by 1712 + │ │ │ │ ├── columns: x:1!null bool_or:10 1713 + │ │ │ │ ├── grouping columns: x:1!null 1714 + │ │ │ │ ├── key: (1) 1715 + │ │ │ │ ├── fd: (1)-->(10) 1716 + │ │ │ │ ├── left-join-apply 1717 + │ │ │ │ │ ├── columns: x:1!null notnull:9 1718 + │ │ │ │ │ ├── key: (1) 1719 + │ │ │ │ │ ├── fd: (1)-->(9) 1720 + │ │ │ │ │ ├── scan xy 1721 + │ │ │ │ │ │ ├── columns: x:1!null 1722 + │ │ │ │ │ │ └── key: (1) 1723 + │ │ │ │ │ ├── project 1724 + │ │ │ │ │ │ ├── columns: notnull:9!null 1725 + │ │ │ │ │ │ ├── outer: (1) 1726 + │ │ │ │ │ │ ├── cardinality: [0 - 1] 1727 + │ │ │ │ │ │ ├── key: () 1728 + │ │ │ │ │ │ ├── fd: ()-->(9) 1729 + │ │ │ │ │ │ ├── select 1730 + │ │ │ │ │ │ │ ├── columns: k:3!null i:4 1731 + │ │ │ │ │ │ │ ├── outer: (1) 1732 + │ │ │ │ │ │ │ ├── cardinality: [0 - 1] 1733 + │ │ │ │ │ │ │ ├── key: () 1734 + │ │ │ │ │ │ │ ├── fd: ()-->(3,4) 1735 + │ │ │ │ │ │ │ ├── scan a 1736 + │ │ │ │ │ │ │ │ ├── columns: k:3!null i:4 1737 + │ │ │ │ │ │ │ │ ├── key: (3) 1738 + │ │ │ │ │ │ │ │ └── fd: (3)-->(4) 1739 + │ │ │ │ │ │ │ └── filters 1740 + │ │ │ │ │ │ │ ├── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1741 + │ │ │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 1742 + │ │ │ │ │ │ └── projections 1743 + │ │ │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 1744 + │ │ │ │ │ └── filters (true) 1745 + │ │ │ │ └── aggregations 1746 + │ │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 1747 + │ │ │ │ └── notnull:9 1748 │ │ │ └── filters (true) 1749 │ │ └── projections 1750 │ │ └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 1751 │ └── filters (true) 1752 └── projections 1753 └── case:11 [as=r:8, outer=(11)] 1754 ================================================================================ 1755 TryDecorrelateProjectSelect 1756 Cost: 2280.15 1757 ================================================================================ 1758 project 1759 ├── columns: r:8 1760 ├── select 1761 │ ├── columns: x:1!null case:11 1762 │ ├── key: (1) 1763 │ ├── fd: (1)-->(11) 1764 │ ├── project 1765 │ │ ├── columns: case:11 x:1!null 1766 │ │ ├── key: (1) 1767 │ │ ├── fd: (1)-->(11) 1768 │ │ ├── select 1769 │ │ │ ├── columns: x:1!null bool_or:10 1770 │ │ │ ├── key: (1) 1771 │ │ │ ├── fd: (1)-->(10) 1772 │ │ │ ├── project 1773 │ │ │ │ ├── columns: x:1!null bool_or:10 1774 │ │ │ │ ├── key: (1) 1775 │ │ │ │ ├── fd: (1)-->(10) 1776 │ │ │ │ └── group-by 1777 │ │ │ │ ├── columns: x:1!null bool_or:10 1778 │ │ │ │ ├── grouping columns: x:1!null 1779 │ │ │ │ ├── key: (1) 1780 │ │ │ │ ├── fd: (1)-->(10) 1781 - │ │ │ │ ├── left-join-apply 1782 + │ │ │ │ ├── project 1783 │ │ │ │ │ ├── columns: x:1!null notnull:9 1784 │ │ │ │ │ ├── key: (1) 1785 │ │ │ │ │ ├── fd: (1)-->(9) 1786 - │ │ │ │ │ ├── scan xy 1787 - │ │ │ │ │ │ ├── columns: x:1!null 1788 - │ │ │ │ │ │ └── key: (1) 1789 - │ │ │ │ │ ├── project 1790 - │ │ │ │ │ │ ├── columns: notnull:9!null 1791 - │ │ │ │ │ │ ├── outer: (1) 1792 - │ │ │ │ │ │ ├── cardinality: [0 - 1] 1793 - │ │ │ │ │ │ ├── key: () 1794 - │ │ │ │ │ │ ├── fd: ()-->(9) 1795 - │ │ │ │ │ │ ├── select 1796 - │ │ │ │ │ │ │ ├── columns: k:3!null i:4 1797 - │ │ │ │ │ │ │ ├── outer: (1) 1798 - │ │ │ │ │ │ │ ├── cardinality: [0 - 1] 1799 - │ │ │ │ │ │ │ ├── key: () 1800 - │ │ │ │ │ │ │ ├── fd: ()-->(3,4) 1801 - │ │ │ │ │ │ │ ├── scan a 1802 - │ │ │ │ │ │ │ │ ├── columns: k:3!null i:4 1803 - │ │ │ │ │ │ │ │ ├── key: (3) 1804 - │ │ │ │ │ │ │ │ └── fd: (3)-->(4) 1805 - │ │ │ │ │ │ │ └── filters 1806 - │ │ │ │ │ │ │ ├── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1807 - │ │ │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 1808 - │ │ │ │ │ │ └── projections 1809 - │ │ │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 1810 - │ │ │ │ │ └── filters (true) 1811 + │ │ │ │ │ └── left-join-apply 1812 + │ │ │ │ │ ├── columns: x:1!null k:3 i:4 notnull:9 1813 + │ │ │ │ │ ├── key: (1) 1814 + │ │ │ │ │ ├── fd: (1)-->(3,4,9) 1815 + │ │ │ │ │ ├── scan xy 1816 + │ │ │ │ │ │ ├── columns: x:1!null 1817 + │ │ │ │ │ │ └── key: (1) 1818 + │ │ │ │ │ ├── project 1819 + │ │ │ │ │ │ ├── columns: notnull:9!null k:3!null i:4 1820 + │ │ │ │ │ │ ├── key: (3) 1821 + │ │ │ │ │ │ ├── fd: (3)-->(4), (4)-->(9) 1822 + │ │ │ │ │ │ ├── scan a 1823 + │ │ │ │ │ │ │ ├── columns: k:3!null i:4 1824 + │ │ │ │ │ │ │ ├── key: (3) 1825 + │ │ │ │ │ │ │ └── fd: (3)-->(4) 1826 + │ │ │ │ │ │ └── projections 1827 + │ │ │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 1828 + │ │ │ │ │ └── filters 1829 + │ │ │ │ │ ├── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1830 + │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 1831 │ │ │ │ └── aggregations 1832 │ │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 1833 │ │ │ │ └── notnull:9 1834 │ │ │ └── filters (true) 1835 │ │ └── projections 1836 │ │ └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 1837 │ └── filters (true) 1838 └── projections 1839 └── case:11 [as=r:8, outer=(11)] 1840 ================================================================================ 1841 DecorrelateJoin 1842 Cost: 2280.15 1843 ================================================================================ 1844 project 1845 ├── columns: r:8 1846 ├── select 1847 │ ├── columns: x:1!null case:11 1848 │ ├── key: (1) 1849 │ ├── fd: (1)-->(11) 1850 │ ├── project 1851 │ │ ├── columns: case:11 x:1!null 1852 │ │ ├── key: (1) 1853 │ │ ├── fd: (1)-->(11) 1854 │ │ ├── select 1855 │ │ │ ├── columns: x:1!null bool_or:10 1856 │ │ │ ├── key: (1) 1857 │ │ │ ├── fd: (1)-->(10) 1858 │ │ │ ├── project 1859 │ │ │ │ ├── columns: x:1!null bool_or:10 1860 │ │ │ │ ├── key: (1) 1861 │ │ │ │ ├── fd: (1)-->(10) 1862 │ │ │ │ └── group-by 1863 │ │ │ │ ├── columns: x:1!null bool_or:10 1864 │ │ │ │ ├── grouping columns: x:1!null 1865 │ │ │ │ ├── key: (1) 1866 │ │ │ │ ├── fd: (1)-->(10) 1867 │ │ │ │ ├── project 1868 │ │ │ │ │ ├── columns: x:1!null notnull:9 1869 │ │ │ │ │ ├── key: (1) 1870 │ │ │ │ │ ├── fd: (1)-->(9) 1871 - │ │ │ │ │ └── left-join-apply 1872 + │ │ │ │ │ └── left-join (hash) 1873 │ │ │ │ │ ├── columns: x:1!null k:3 i:4 notnull:9 1874 │ │ │ │ │ ├── key: (1) 1875 - │ │ │ │ │ ├── fd: (1)-->(3,4,9) 1876 + │ │ │ │ │ ├── fd: (3)-->(4), (4)~~>(9), (1)-->(3,4,9) 1877 │ │ │ │ │ ├── scan xy 1878 │ │ │ │ │ │ ├── columns: x:1!null 1879 │ │ │ │ │ │ └── key: (1) 1880 │ │ │ │ │ ├── project 1881 │ │ │ │ │ │ ├── columns: notnull:9!null k:3!null i:4 1882 │ │ │ │ │ │ ├── key: (3) 1883 │ │ │ │ │ │ ├── fd: (3)-->(4), (4)-->(9) 1884 │ │ │ │ │ │ ├── scan a 1885 │ │ │ │ │ │ │ ├── columns: k:3!null i:4 1886 │ │ │ │ │ │ │ ├── key: (3) 1887 │ │ │ │ │ │ │ └── fd: (3)-->(4) 1888 │ │ │ │ │ │ └── projections 1889 │ │ │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 1890 │ │ │ │ │ └── filters 1891 │ │ │ │ │ ├── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1892 │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 1893 │ │ │ │ └── aggregations 1894 │ │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 1895 │ │ │ │ └── notnull:9 1896 │ │ │ └── filters (true) 1897 │ │ └── projections 1898 │ │ └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 1899 │ └── filters (true) 1900 └── projections 1901 └── case:11 [as=r:8, outer=(11)] 1902 ================================================================================ 1903 PushFilterIntoJoinRight 1904 Cost: 2278.48 1905 ================================================================================ 1906 project 1907 ├── columns: r:8 1908 ├── select 1909 │ ├── columns: x:1!null case:11 1910 │ ├── key: (1) 1911 │ ├── fd: (1)-->(11) 1912 │ ├── project 1913 │ │ ├── columns: case:11 x:1!null 1914 │ │ ├── key: (1) 1915 │ │ ├── fd: (1)-->(11) 1916 │ │ ├── select 1917 │ │ │ ├── columns: x:1!null bool_or:10 1918 │ │ │ ├── key: (1) 1919 │ │ │ ├── fd: (1)-->(10) 1920 │ │ │ ├── project 1921 │ │ │ │ ├── columns: x:1!null bool_or:10 1922 │ │ │ │ ├── key: (1) 1923 │ │ │ │ ├── fd: (1)-->(10) 1924 │ │ │ │ └── group-by 1925 │ │ │ │ ├── columns: x:1!null bool_or:10 1926 │ │ │ │ ├── grouping columns: x:1!null 1927 │ │ │ │ ├── key: (1) 1928 │ │ │ │ ├── fd: (1)-->(10) 1929 │ │ │ │ ├── project 1930 │ │ │ │ │ ├── columns: x:1!null notnull:9 1931 │ │ │ │ │ ├── key: (1) 1932 │ │ │ │ │ ├── fd: (1)-->(9) 1933 │ │ │ │ │ └── left-join (hash) 1934 │ │ │ │ │ ├── columns: x:1!null k:3 i:4 notnull:9 1935 │ │ │ │ │ ├── key: (1) 1936 │ │ │ │ │ ├── fd: (3)-->(4), (4)~~>(9), (1)-->(3,4,9) 1937 │ │ │ │ │ ├── scan xy 1938 │ │ │ │ │ │ ├── columns: x:1!null 1939 │ │ │ │ │ │ └── key: (1) 1940 - │ │ │ │ │ ├── project 1941 - │ │ │ │ │ │ ├── columns: notnull:9!null k:3!null i:4 1942 + │ │ │ │ │ ├── select 1943 + │ │ │ │ │ │ ├── columns: k:3!null i:4 notnull:9!null 1944 │ │ │ │ │ │ ├── key: (3) 1945 │ │ │ │ │ │ ├── fd: (3)-->(4), (4)-->(9) 1946 - │ │ │ │ │ │ ├── scan a 1947 - │ │ │ │ │ │ │ ├── columns: k:3!null i:4 1948 + │ │ │ │ │ │ ├── project 1949 + │ │ │ │ │ │ │ ├── columns: notnull:9!null k:3!null i:4 1950 │ │ │ │ │ │ │ ├── key: (3) 1951 - │ │ │ │ │ │ │ └── fd: (3)-->(4) 1952 - │ │ │ │ │ │ └── projections 1953 - │ │ │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 1954 + │ │ │ │ │ │ │ ├── fd: (3)-->(4), (4)-->(9) 1955 + │ │ │ │ │ │ │ ├── scan a 1956 + │ │ │ │ │ │ │ │ ├── columns: k:3!null i:4 1957 + │ │ │ │ │ │ │ │ ├── key: (3) 1958 + │ │ │ │ │ │ │ │ └── fd: (3)-->(4) 1959 + │ │ │ │ │ │ │ └── projections 1960 + │ │ │ │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 1961 + │ │ │ │ │ │ └── filters 1962 + │ │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 1963 │ │ │ │ │ └── filters 1964 - │ │ │ │ │ ├── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1965 - │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 1966 + │ │ │ │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 1967 │ │ │ │ └── aggregations 1968 │ │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 1969 │ │ │ │ └── notnull:9 1970 │ │ │ └── filters (true) 1971 │ │ └── projections 1972 │ │ └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 1973 │ └── filters (true) 1974 └── projections 1975 └── case:11 [as=r:8, outer=(11)] 1976 ================================================================================ 1977 PushSelectIntoProject 1978 Cost: 2268.49 1979 ================================================================================ 1980 project 1981 ├── columns: r:8 1982 ├── select 1983 │ ├── columns: x:1!null case:11 1984 │ ├── key: (1) 1985 │ ├── fd: (1)-->(11) 1986 │ ├── project 1987 │ │ ├── columns: case:11 x:1!null 1988 │ │ ├── key: (1) 1989 │ │ ├── fd: (1)-->(11) 1990 │ │ ├── select 1991 │ │ │ ├── columns: x:1!null bool_or:10 1992 │ │ │ ├── key: (1) 1993 │ │ │ ├── fd: (1)-->(10) 1994 │ │ │ ├── project 1995 │ │ │ │ ├── columns: x:1!null bool_or:10 1996 │ │ │ │ ├── key: (1) 1997 │ │ │ │ ├── fd: (1)-->(10) 1998 │ │ │ │ └── group-by 1999 │ │ │ │ ├── columns: x:1!null bool_or:10 2000 │ │ │ │ ├── grouping columns: x:1!null 2001 │ │ │ │ ├── key: (1) 2002 │ │ │ │ ├── fd: (1)-->(10) 2003 │ │ │ │ ├── project 2004 │ │ │ │ │ ├── columns: x:1!null notnull:9 2005 │ │ │ │ │ ├── key: (1) 2006 │ │ │ │ │ ├── fd: (1)-->(9) 2007 │ │ │ │ │ └── left-join (hash) 2008 │ │ │ │ │ ├── columns: x:1!null k:3 i:4 notnull:9 2009 │ │ │ │ │ ├── key: (1) 2010 │ │ │ │ │ ├── fd: (3)-->(4), (4)~~>(9), (1)-->(3,4,9) 2011 │ │ │ │ │ ├── scan xy 2012 │ │ │ │ │ │ ├── columns: x:1!null 2013 │ │ │ │ │ │ └── key: (1) 2014 │ │ │ │ │ ├── select 2015 │ │ │ │ │ │ ├── columns: k:3!null i:4 notnull:9!null 2016 │ │ │ │ │ │ ├── key: (3) 2017 │ │ │ │ │ │ ├── fd: (3)-->(4), (4)-->(9) 2018 │ │ │ │ │ │ ├── project 2019 │ │ │ │ │ │ │ ├── columns: notnull:9!null k:3!null i:4 2020 │ │ │ │ │ │ │ ├── key: (3) 2021 │ │ │ │ │ │ │ ├── fd: (3)-->(4), (4)-->(9) 2022 - │ │ │ │ │ │ │ ├── scan a 2023 + │ │ │ │ │ │ │ ├── select 2024 │ │ │ │ │ │ │ │ ├── columns: k:3!null i:4 2025 │ │ │ │ │ │ │ │ ├── key: (3) 2026 - │ │ │ │ │ │ │ │ └── fd: (3)-->(4) 2027 + │ │ │ │ │ │ │ │ ├── fd: (3)-->(4) 2028 + │ │ │ │ │ │ │ │ ├── scan a 2029 + │ │ │ │ │ │ │ │ │ ├── columns: k:3!null i:4 2030 + │ │ │ │ │ │ │ │ │ ├── key: (3) 2031 + │ │ │ │ │ │ │ │ │ └── fd: (3)-->(4) 2032 + │ │ │ │ │ │ │ │ └── filters 2033 + │ │ │ │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2034 │ │ │ │ │ │ │ └── projections 2035 │ │ │ │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 2036 - │ │ │ │ │ │ └── filters 2037 - │ │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2038 + │ │ │ │ │ │ └── filters (true) 2039 │ │ │ │ │ └── filters 2040 │ │ │ │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 2041 │ │ │ │ └── aggregations 2042 │ │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 2043 │ │ │ │ └── notnull:9 2044 │ │ │ └── filters (true) 2045 │ │ └── projections 2046 │ │ └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 2047 │ └── filters (true) 2048 └── projections 2049 └── case:11 [as=r:8, outer=(11)] 2050 ================================================================================ 2051 EliminateSelect 2052 Cost: 2265.15 2053 ================================================================================ 2054 project 2055 ├── columns: r:8 2056 ├── select 2057 │ ├── columns: x:1!null case:11 2058 │ ├── key: (1) 2059 │ ├── fd: (1)-->(11) 2060 │ ├── project 2061 │ │ ├── columns: case:11 x:1!null 2062 │ │ ├── key: (1) 2063 │ │ ├── fd: (1)-->(11) 2064 │ │ ├── select 2065 │ │ │ ├── columns: x:1!null bool_or:10 2066 │ │ │ ├── key: (1) 2067 │ │ │ ├── fd: (1)-->(10) 2068 │ │ │ ├── project 2069 │ │ │ │ ├── columns: x:1!null bool_or:10 2070 │ │ │ │ ├── key: (1) 2071 │ │ │ │ ├── fd: (1)-->(10) 2072 │ │ │ │ └── group-by 2073 │ │ │ │ ├── columns: x:1!null bool_or:10 2074 │ │ │ │ ├── grouping columns: x:1!null 2075 │ │ │ │ ├── key: (1) 2076 │ │ │ │ ├── fd: (1)-->(10) 2077 │ │ │ │ ├── project 2078 │ │ │ │ │ ├── columns: x:1!null notnull:9 2079 │ │ │ │ │ ├── key: (1) 2080 │ │ │ │ │ ├── fd: (1)-->(9) 2081 │ │ │ │ │ └── left-join (hash) 2082 │ │ │ │ │ ├── columns: x:1!null k:3 i:4 notnull:9 2083 │ │ │ │ │ ├── key: (1) 2084 │ │ │ │ │ ├── fd: (3)-->(4), (4)~~>(9), (1)-->(3,4,9) 2085 │ │ │ │ │ ├── scan xy 2086 │ │ │ │ │ │ ├── columns: x:1!null 2087 │ │ │ │ │ │ └── key: (1) 2088 - │ │ │ │ │ ├── select 2089 - │ │ │ │ │ │ ├── columns: k:3!null i:4 notnull:9!null 2090 + │ │ │ │ │ ├── project 2091 + │ │ │ │ │ │ ├── columns: notnull:9!null k:3!null i:4 2092 │ │ │ │ │ │ ├── key: (3) 2093 │ │ │ │ │ │ ├── fd: (3)-->(4), (4)-->(9) 2094 - │ │ │ │ │ │ ├── project 2095 - │ │ │ │ │ │ │ ├── columns: notnull:9!null k:3!null i:4 2096 + │ │ │ │ │ │ ├── select 2097 + │ │ │ │ │ │ │ ├── columns: k:3!null i:4 2098 │ │ │ │ │ │ │ ├── key: (3) 2099 - │ │ │ │ │ │ │ ├── fd: (3)-->(4), (4)-->(9) 2100 - │ │ │ │ │ │ │ ├── select 2101 + │ │ │ │ │ │ │ ├── fd: (3)-->(4) 2102 + │ │ │ │ │ │ │ ├── scan a 2103 │ │ │ │ │ │ │ │ ├── columns: k:3!null i:4 2104 │ │ │ │ │ │ │ │ ├── key: (3) 2105 - │ │ │ │ │ │ │ │ ├── fd: (3)-->(4) 2106 - │ │ │ │ │ │ │ │ ├── scan a 2107 - │ │ │ │ │ │ │ │ │ ├── columns: k:3!null i:4 2108 - │ │ │ │ │ │ │ │ │ ├── key: (3) 2109 - │ │ │ │ │ │ │ │ │ └── fd: (3)-->(4) 2110 - │ │ │ │ │ │ │ │ └── filters 2111 - │ │ │ │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2112 - │ │ │ │ │ │ │ └── projections 2113 - │ │ │ │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 2114 - │ │ │ │ │ │ └── filters (true) 2115 + │ │ │ │ │ │ │ │ └── fd: (3)-->(4) 2116 + │ │ │ │ │ │ │ └── filters 2117 + │ │ │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2118 + │ │ │ │ │ │ └── projections 2119 + │ │ │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 2120 │ │ │ │ │ └── filters 2121 │ │ │ │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 2122 │ │ │ │ └── aggregations 2123 │ │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 2124 │ │ │ │ └── notnull:9 2125 │ │ │ └── filters (true) 2126 │ │ └── projections 2127 │ │ └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 2128 │ └── filters (true) 2129 └── projections 2130 └── case:11 [as=r:8, outer=(11)] 2131 ================================================================================ 2132 PruneJoinRightCols 2133 Cost: 2265.15 2134 ================================================================================ 2135 project 2136 ├── columns: r:8 2137 ├── select 2138 │ ├── columns: x:1!null case:11 2139 │ ├── key: (1) 2140 │ ├── fd: (1)-->(11) 2141 │ ├── project 2142 │ │ ├── columns: case:11 x:1!null 2143 │ │ ├── key: (1) 2144 │ │ ├── fd: (1)-->(11) 2145 │ │ ├── select 2146 │ │ │ ├── columns: x:1!null bool_or:10 2147 │ │ │ ├── key: (1) 2148 │ │ │ ├── fd: (1)-->(10) 2149 │ │ │ ├── project 2150 │ │ │ │ ├── columns: x:1!null bool_or:10 2151 │ │ │ │ ├── key: (1) 2152 │ │ │ │ ├── fd: (1)-->(10) 2153 │ │ │ │ └── group-by 2154 │ │ │ │ ├── columns: x:1!null bool_or:10 2155 │ │ │ │ ├── grouping columns: x:1!null 2156 │ │ │ │ ├── key: (1) 2157 │ │ │ │ ├── fd: (1)-->(10) 2158 │ │ │ │ ├── project 2159 │ │ │ │ │ ├── columns: x:1!null notnull:9 2160 │ │ │ │ │ ├── key: (1) 2161 │ │ │ │ │ ├── fd: (1)-->(9) 2162 │ │ │ │ │ └── left-join (hash) 2163 - │ │ │ │ │ ├── columns: x:1!null k:3 i:4 notnull:9 2164 + │ │ │ │ │ ├── columns: x:1!null k:3 notnull:9 2165 │ │ │ │ │ ├── key: (1) 2166 - │ │ │ │ │ ├── fd: (3)-->(4), (4)~~>(9), (1)-->(3,4,9) 2167 + │ │ │ │ │ ├── fd: (3)-->(9), (1)-->(3,9) 2168 │ │ │ │ │ ├── scan xy 2169 │ │ │ │ │ │ ├── columns: x:1!null 2170 │ │ │ │ │ │ └── key: (1) 2171 │ │ │ │ │ ├── project 2172 - │ │ │ │ │ │ ├── columns: notnull:9!null k:3!null i:4 2173 + │ │ │ │ │ │ ├── columns: notnull:9!null k:3!null 2174 │ │ │ │ │ │ ├── key: (3) 2175 - │ │ │ │ │ │ ├── fd: (3)-->(4), (4)-->(9) 2176 + │ │ │ │ │ │ ├── fd: (3)-->(9) 2177 │ │ │ │ │ │ ├── select 2178 │ │ │ │ │ │ │ ├── columns: k:3!null i:4 2179 │ │ │ │ │ │ │ ├── key: (3) 2180 │ │ │ │ │ │ │ ├── fd: (3)-->(4) 2181 │ │ │ │ │ │ │ ├── scan a 2182 │ │ │ │ │ │ │ │ ├── columns: k:3!null i:4 2183 │ │ │ │ │ │ │ │ ├── key: (3) 2184 │ │ │ │ │ │ │ │ └── fd: (3)-->(4) 2185 │ │ │ │ │ │ │ └── filters 2186 │ │ │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2187 │ │ │ │ │ │ └── projections 2188 │ │ │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 2189 │ │ │ │ │ └── filters 2190 │ │ │ │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 2191 │ │ │ │ └── aggregations 2192 │ │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 2193 │ │ │ │ └── notnull:9 2194 │ │ │ └── filters (true) 2195 │ │ └── projections 2196 │ │ └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 2197 │ └── filters (true) 2198 └── projections 2199 └── case:11 [as=r:8, outer=(11)] 2200 ================================================================================ 2201 EliminateGroupByProject 2202 Cost: 2255.14 2203 ================================================================================ 2204 project 2205 ├── columns: r:8 2206 ├── select 2207 │ ├── columns: x:1!null case:11 2208 │ ├── key: (1) 2209 │ ├── fd: (1)-->(11) 2210 │ ├── project 2211 │ │ ├── columns: case:11 x:1!null 2212 │ │ ├── key: (1) 2213 │ │ ├── fd: (1)-->(11) 2214 │ │ ├── select 2215 │ │ │ ├── columns: x:1!null bool_or:10 2216 │ │ │ ├── key: (1) 2217 │ │ │ ├── fd: (1)-->(10) 2218 │ │ │ ├── project 2219 │ │ │ │ ├── columns: x:1!null bool_or:10 2220 │ │ │ │ ├── key: (1) 2221 │ │ │ │ ├── fd: (1)-->(10) 2222 │ │ │ │ └── group-by 2223 │ │ │ │ ├── columns: x:1!null bool_or:10 2224 │ │ │ │ ├── grouping columns: x:1!null 2225 │ │ │ │ ├── key: (1) 2226 │ │ │ │ ├── fd: (1)-->(10) 2227 - │ │ │ │ ├── project 2228 - │ │ │ │ │ ├── columns: x:1!null notnull:9 2229 + │ │ │ │ ├── left-join (hash) 2230 + │ │ │ │ │ ├── columns: x:1!null k:3 notnull:9 2231 │ │ │ │ │ ├── key: (1) 2232 - │ │ │ │ │ ├── fd: (1)-->(9) 2233 - │ │ │ │ │ └── left-join (hash) 2234 - │ │ │ │ │ ├── columns: x:1!null k:3 notnull:9 2235 - │ │ │ │ │ ├── key: (1) 2236 - │ │ │ │ │ ├── fd: (3)-->(9), (1)-->(3,9) 2237 - │ │ │ │ │ ├── scan xy 2238 - │ │ │ │ │ │ ├── columns: x:1!null 2239 - │ │ │ │ │ │ └── key: (1) 2240 - │ │ │ │ │ ├── project 2241 - │ │ │ │ │ │ ├── columns: notnull:9!null k:3!null 2242 - │ │ │ │ │ │ ├── key: (3) 2243 - │ │ │ │ │ │ ├── fd: (3)-->(9) 2244 - │ │ │ │ │ │ ├── select 2245 - │ │ │ │ │ │ │ ├── columns: k:3!null i:4 2246 - │ │ │ │ │ │ │ ├── key: (3) 2247 - │ │ │ │ │ │ │ ├── fd: (3)-->(4) 2248 - │ │ │ │ │ │ │ ├── scan a 2249 - │ │ │ │ │ │ │ │ ├── columns: k:3!null i:4 2250 - │ │ │ │ │ │ │ │ ├── key: (3) 2251 - │ │ │ │ │ │ │ │ └── fd: (3)-->(4) 2252 - │ │ │ │ │ │ │ └── filters 2253 - │ │ │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2254 - │ │ │ │ │ │ └── projections 2255 - │ │ │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 2256 - │ │ │ │ │ └── filters 2257 - │ │ │ │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 2258 + │ │ │ │ │ ├── fd: (3)-->(9), (1)-->(3,9) 2259 + │ │ │ │ │ ├── scan xy 2260 + │ │ │ │ │ │ ├── columns: x:1!null 2261 + │ │ │ │ │ │ └── key: (1) 2262 + │ │ │ │ │ ├── project 2263 + │ │ │ │ │ │ ├── columns: notnull:9!null k:3!null 2264 + │ │ │ │ │ │ ├── key: (3) 2265 + │ │ │ │ │ │ ├── fd: (3)-->(9) 2266 + │ │ │ │ │ │ ├── select 2267 + │ │ │ │ │ │ │ ├── columns: k:3!null i:4 2268 + │ │ │ │ │ │ │ ├── key: (3) 2269 + │ │ │ │ │ │ │ ├── fd: (3)-->(4) 2270 + │ │ │ │ │ │ │ ├── scan a 2271 + │ │ │ │ │ │ │ │ ├── columns: k:3!null i:4 2272 + │ │ │ │ │ │ │ │ ├── key: (3) 2273 + │ │ │ │ │ │ │ │ └── fd: (3)-->(4) 2274 + │ │ │ │ │ │ │ └── filters 2275 + │ │ │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2276 + │ │ │ │ │ │ └── projections 2277 + │ │ │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 2278 + │ │ │ │ │ └── filters 2279 + │ │ │ │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 2280 │ │ │ │ └── aggregations 2281 │ │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 2282 │ │ │ │ └── notnull:9 2283 │ │ │ └── filters (true) 2284 │ │ └── projections 2285 │ │ └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 2286 │ └── filters (true) 2287 └── projections 2288 └── case:11 [as=r:8, outer=(11)] 2289 ================================================================================ 2290 EliminateProject 2291 Cost: 2245.13 2292 ================================================================================ 2293 project 2294 ├── columns: r:8 2295 ├── select 2296 │ ├── columns: x:1!null case:11 2297 │ ├── key: (1) 2298 │ ├── fd: (1)-->(11) 2299 │ ├── project 2300 │ │ ├── columns: case:11 x:1!null 2301 │ │ ├── key: (1) 2302 │ │ ├── fd: (1)-->(11) 2303 │ │ ├── select 2304 │ │ │ ├── columns: x:1!null bool_or:10 2305 │ │ │ ├── key: (1) 2306 │ │ │ ├── fd: (1)-->(10) 2307 - │ │ │ ├── project 2308 + │ │ │ ├── group-by 2309 │ │ │ │ ├── columns: x:1!null bool_or:10 2310 + │ │ │ │ ├── grouping columns: x:1!null 2311 │ │ │ │ ├── key: (1) 2312 │ │ │ │ ├── fd: (1)-->(10) 2313 - │ │ │ │ └── group-by 2314 - │ │ │ │ ├── columns: x:1!null bool_or:10 2315 - │ │ │ │ ├── grouping columns: x:1!null 2316 - │ │ │ │ ├── key: (1) 2317 - │ │ │ │ ├── fd: (1)-->(10) 2318 - │ │ │ │ ├── left-join (hash) 2319 - │ │ │ │ │ ├── columns: x:1!null k:3 notnull:9 2320 - │ │ │ │ │ ├── key: (1) 2321 - │ │ │ │ │ ├── fd: (3)-->(9), (1)-->(3,9) 2322 - │ │ │ │ │ ├── scan xy 2323 - │ │ │ │ │ │ ├── columns: x:1!null 2324 - │ │ │ │ │ │ └── key: (1) 2325 - │ │ │ │ │ ├── project 2326 - │ │ │ │ │ │ ├── columns: notnull:9!null k:3!null 2327 - │ │ │ │ │ │ ├── key: (3) 2328 - │ │ │ │ │ │ ├── fd: (3)-->(9) 2329 - │ │ │ │ │ │ ├── select 2330 - │ │ │ │ │ │ │ ├── columns: k:3!null i:4 2331 - │ │ │ │ │ │ │ ├── key: (3) 2332 - │ │ │ │ │ │ │ ├── fd: (3)-->(4) 2333 - │ │ │ │ │ │ │ ├── scan a 2334 - │ │ │ │ │ │ │ │ ├── columns: k:3!null i:4 2335 - │ │ │ │ │ │ │ │ ├── key: (3) 2336 - │ │ │ │ │ │ │ │ └── fd: (3)-->(4) 2337 - │ │ │ │ │ │ │ └── filters 2338 - │ │ │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2339 - │ │ │ │ │ │ └── projections 2340 - │ │ │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 2341 - │ │ │ │ │ └── filters 2342 - │ │ │ │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 2343 - │ │ │ │ └── aggregations 2344 - │ │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 2345 - │ │ │ │ └── notnull:9 2346 + │ │ │ │ ├── left-join (hash) 2347 + │ │ │ │ │ ├── columns: x:1!null k:3 notnull:9 2348 + │ │ │ │ │ ├── key: (1) 2349 + │ │ │ │ │ ├── fd: (3)-->(9), (1)-->(3,9) 2350 + │ │ │ │ │ ├── scan xy 2351 + │ │ │ │ │ │ ├── columns: x:1!null 2352 + │ │ │ │ │ │ └── key: (1) 2353 + │ │ │ │ │ ├── project 2354 + │ │ │ │ │ │ ├── columns: notnull:9!null k:3!null 2355 + │ │ │ │ │ │ ├── key: (3) 2356 + │ │ │ │ │ │ ├── fd: (3)-->(9) 2357 + │ │ │ │ │ │ ├── select 2358 + │ │ │ │ │ │ │ ├── columns: k:3!null i:4 2359 + │ │ │ │ │ │ │ ├── key: (3) 2360 + │ │ │ │ │ │ │ ├── fd: (3)-->(4) 2361 + │ │ │ │ │ │ │ ├── scan a 2362 + │ │ │ │ │ │ │ │ ├── columns: k:3!null i:4 2363 + │ │ │ │ │ │ │ │ ├── key: (3) 2364 + │ │ │ │ │ │ │ │ └── fd: (3)-->(4) 2365 + │ │ │ │ │ │ │ └── filters 2366 + │ │ │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2367 + │ │ │ │ │ │ └── projections 2368 + │ │ │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 2369 + │ │ │ │ │ └── filters 2370 + │ │ │ │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 2371 + │ │ │ │ └── aggregations 2372 + │ │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 2373 + │ │ │ │ └── notnull:9 2374 │ │ │ └── filters (true) 2375 │ │ └── projections 2376 │ │ └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 2377 │ └── filters (true) 2378 └── projections 2379 └── case:11 [as=r:8, outer=(11)] 2380 ================================================================================ 2381 EliminateSelect 2382 Cost: 2235.12 2383 ================================================================================ 2384 project 2385 ├── columns: r:8 2386 ├── select 2387 │ ├── columns: x:1!null case:11 2388 │ ├── key: (1) 2389 │ ├── fd: (1)-->(11) 2390 │ ├── project 2391 │ │ ├── columns: case:11 x:1!null 2392 │ │ ├── key: (1) 2393 │ │ ├── fd: (1)-->(11) 2394 - │ │ ├── select 2395 + │ │ ├── group-by 2396 │ │ │ ├── columns: x:1!null bool_or:10 2397 + │ │ │ ├── grouping columns: x:1!null 2398 │ │ │ ├── key: (1) 2399 │ │ │ ├── fd: (1)-->(10) 2400 - │ │ │ ├── group-by 2401 - │ │ │ │ ├── columns: x:1!null bool_or:10 2402 - │ │ │ │ ├── grouping columns: x:1!null 2403 + │ │ │ ├── left-join (hash) 2404 + │ │ │ │ ├── columns: x:1!null k:3 notnull:9 2405 │ │ │ │ ├── key: (1) 2406 - │ │ │ │ ├── fd: (1)-->(10) 2407 - │ │ │ │ ├── left-join (hash) 2408 - │ │ │ │ │ ├── columns: x:1!null k:3 notnull:9 2409 - │ │ │ │ │ ├── key: (1) 2410 - │ │ │ │ │ ├── fd: (3)-->(9), (1)-->(3,9) 2411 - │ │ │ │ │ ├── scan xy 2412 - │ │ │ │ │ │ ├── columns: x:1!null 2413 - │ │ │ │ │ │ └── key: (1) 2414 - │ │ │ │ │ ├── project 2415 - │ │ │ │ │ │ ├── columns: notnull:9!null k:3!null 2416 + │ │ │ │ ├── fd: (3)-->(9), (1)-->(3,9) 2417 + │ │ │ │ ├── scan xy 2418 + │ │ │ │ │ ├── columns: x:1!null 2419 + │ │ │ │ │ └── key: (1) 2420 + │ │ │ │ ├── project 2421 + │ │ │ │ │ ├── columns: notnull:9!null k:3!null 2422 + │ │ │ │ │ ├── key: (3) 2423 + │ │ │ │ │ ├── fd: (3)-->(9) 2424 + │ │ │ │ │ ├── select 2425 + │ │ │ │ │ │ ├── columns: k:3!null i:4 2426 │ │ │ │ │ │ ├── key: (3) 2427 - │ │ │ │ │ │ ├── fd: (3)-->(9) 2428 - │ │ │ │ │ │ ├── select 2429 + │ │ │ │ │ │ ├── fd: (3)-->(4) 2430 + │ │ │ │ │ │ ├── scan a 2431 │ │ │ │ │ │ │ ├── columns: k:3!null i:4 2432 │ │ │ │ │ │ │ ├── key: (3) 2433 - │ │ │ │ │ │ │ ├── fd: (3)-->(4) 2434 - │ │ │ │ │ │ │ ├── scan a 2435 - │ │ │ │ │ │ │ │ ├── columns: k:3!null i:4 2436 - │ │ │ │ │ │ │ │ ├── key: (3) 2437 - │ │ │ │ │ │ │ │ └── fd: (3)-->(4) 2438 - │ │ │ │ │ │ │ └── filters 2439 - │ │ │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2440 - │ │ │ │ │ │ └── projections 2441 - │ │ │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 2442 - │ │ │ │ │ └── filters 2443 - │ │ │ │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 2444 - │ │ │ │ └── aggregations 2445 - │ │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 2446 - │ │ │ │ └── notnull:9 2447 - │ │ │ └── filters (true) 2448 + │ │ │ │ │ │ │ └── fd: (3)-->(4) 2449 + │ │ │ │ │ │ └── filters 2450 + │ │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2451 + │ │ │ │ │ └── projections 2452 + │ │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 2453 + │ │ │ │ └── filters 2454 + │ │ │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 2455 + │ │ │ └── aggregations 2456 + │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 2457 + │ │ │ └── notnull:9 2458 │ │ └── projections 2459 │ │ └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 2460 │ └── filters (true) 2461 └── projections 2462 └── case:11 [as=r:8, outer=(11)] 2463 ================================================================================ 2464 EliminateSelect 2465 Cost: 2225.11 2466 ================================================================================ 2467 project 2468 ├── columns: r:8 2469 - ├── select 2470 - │ ├── columns: x:1!null case:11 2471 + ├── project 2472 + │ ├── columns: case:11 x:1!null 2473 │ ├── key: (1) 2474 │ ├── fd: (1)-->(11) 2475 - │ ├── project 2476 - │ │ ├── columns: case:11 x:1!null 2477 + │ ├── group-by 2478 + │ │ ├── columns: x:1!null bool_or:10 2479 + │ │ ├── grouping columns: x:1!null 2480 │ │ ├── key: (1) 2481 - │ │ ├── fd: (1)-->(11) 2482 - │ │ ├── group-by 2483 - │ │ │ ├── columns: x:1!null bool_or:10 2484 - │ │ │ ├── grouping columns: x:1!null 2485 + │ │ ├── fd: (1)-->(10) 2486 + │ │ ├── left-join (hash) 2487 + │ │ │ ├── columns: x:1!null k:3 notnull:9 2488 │ │ │ ├── key: (1) 2489 - │ │ │ ├── fd: (1)-->(10) 2490 - │ │ │ ├── left-join (hash) 2491 - │ │ │ │ ├── columns: x:1!null k:3 notnull:9 2492 - │ │ │ │ ├── key: (1) 2493 - │ │ │ │ ├── fd: (3)-->(9), (1)-->(3,9) 2494 - │ │ │ │ ├── scan xy 2495 - │ │ │ │ │ ├── columns: x:1!null 2496 - │ │ │ │ │ └── key: (1) 2497 - │ │ │ │ ├── project 2498 - │ │ │ │ │ ├── columns: notnull:9!null k:3!null 2499 + │ │ │ ├── fd: (3)-->(9), (1)-->(3,9) 2500 + │ │ │ ├── scan xy 2501 + │ │ │ │ ├── columns: x:1!null 2502 + │ │ │ │ └── key: (1) 2503 + │ │ │ ├── project 2504 + │ │ │ │ ├── columns: notnull:9!null k:3!null 2505 + │ │ │ │ ├── key: (3) 2506 + │ │ │ │ ├── fd: (3)-->(9) 2507 + │ │ │ │ ├── select 2508 + │ │ │ │ │ ├── columns: k:3!null i:4 2509 │ │ │ │ │ ├── key: (3) 2510 - │ │ │ │ │ ├── fd: (3)-->(9) 2511 - │ │ │ │ │ ├── select 2512 + │ │ │ │ │ ├── fd: (3)-->(4) 2513 + │ │ │ │ │ ├── scan a 2514 │ │ │ │ │ │ ├── columns: k:3!null i:4 2515 │ │ │ │ │ │ ├── key: (3) 2516 - │ │ │ │ │ │ ├── fd: (3)-->(4) 2517 - │ │ │ │ │ │ ├── scan a 2518 - │ │ │ │ │ │ │ ├── columns: k:3!null i:4 2519 - │ │ │ │ │ │ │ ├── key: (3) 2520 - │ │ │ │ │ │ │ └── fd: (3)-->(4) 2521 - │ │ │ │ │ │ └── filters 2522 - │ │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2523 - │ │ │ │ │ └── projections 2524 - │ │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 2525 - │ │ │ │ └── filters 2526 - │ │ │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 2527 - │ │ │ └── aggregations 2528 - │ │ │ └── bool-or [as=bool_or:10, outer=(9)] 2529 - │ │ │ └── notnull:9 2530 - │ │ └── projections 2531 - │ │ └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 2532 - │ └── filters (true) 2533 + │ │ │ │ │ │ └── fd: (3)-->(4) 2534 + │ │ │ │ │ └── filters 2535 + │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2536 + │ │ │ │ └── projections 2537 + │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 2538 + │ │ │ └── filters 2539 + │ │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 2540 + │ │ └── aggregations 2541 + │ │ └── bool-or [as=bool_or:10, outer=(9)] 2542 + │ │ └── notnull:9 2543 + │ └── projections 2544 + │ └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 2545 └── projections 2546 └── case:11 [as=r:8, outer=(11)] 2547 ================================================================================ 2548 PruneProjectCols 2549 Cost: 2225.11 2550 ================================================================================ 2551 project 2552 ├── columns: r:8 2553 ├── project 2554 - │ ├── columns: case:11 x:1!null 2555 - │ ├── key: (1) 2556 - │ ├── fd: (1)-->(11) 2557 + │ ├── columns: case:11 2558 │ ├── group-by 2559 │ │ ├── columns: x:1!null bool_or:10 2560 │ │ ├── grouping columns: x:1!null 2561 │ │ ├── key: (1) 2562 │ │ ├── fd: (1)-->(10) 2563 │ │ ├── left-join (hash) 2564 │ │ │ ├── columns: x:1!null k:3 notnull:9 2565 │ │ │ ├── key: (1) 2566 │ │ │ ├── fd: (3)-->(9), (1)-->(3,9) 2567 │ │ │ ├── scan xy 2568 │ │ │ │ ├── columns: x:1!null 2569 │ │ │ │ └── key: (1) 2570 │ │ │ ├── project 2571 │ │ │ │ ├── columns: notnull:9!null k:3!null 2572 │ │ │ │ ├── key: (3) 2573 │ │ │ │ ├── fd: (3)-->(9) 2574 │ │ │ │ ├── select 2575 │ │ │ │ │ ├── columns: k:3!null i:4 2576 │ │ │ │ │ ├── key: (3) 2577 │ │ │ │ │ ├── fd: (3)-->(4) 2578 │ │ │ │ │ ├── scan a 2579 │ │ │ │ │ │ ├── columns: k:3!null i:4 2580 │ │ │ │ │ │ ├── key: (3) 2581 │ │ │ │ │ │ └── fd: (3)-->(4) 2582 │ │ │ │ │ └── filters 2583 │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2584 │ │ │ │ └── projections 2585 │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 2586 │ │ │ └── filters 2587 │ │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 2588 │ │ └── aggregations 2589 │ │ └── bool-or [as=bool_or:10, outer=(9)] 2590 │ │ └── notnull:9 2591 │ └── projections 2592 │ └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 2593 └── projections 2594 └── case:11 [as=r:8, outer=(11)] 2595 ================================================================================ 2596 InlineProjectInProject 2597 Cost: 2205.10 2598 ================================================================================ 2599 project 2600 ├── columns: r:8 2601 - ├── project 2602 - │ ├── columns: case:11 2603 - │ ├── group-by 2604 - │ │ ├── columns: x:1!null bool_or:10 2605 - │ │ ├── grouping columns: x:1!null 2606 + ├── group-by 2607 + │ ├── columns: x:1!null bool_or:10 2608 + │ ├── grouping columns: x:1!null 2609 + │ ├── key: (1) 2610 + │ ├── fd: (1)-->(10) 2611 + │ ├── left-join (hash) 2612 + │ │ ├── columns: x:1!null k:3 notnull:9 2613 │ │ ├── key: (1) 2614 - │ │ ├── fd: (1)-->(10) 2615 - │ │ ├── left-join (hash) 2616 - │ │ │ ├── columns: x:1!null k:3 notnull:9 2617 - │ │ │ ├── key: (1) 2618 - │ │ │ ├── fd: (3)-->(9), (1)-->(3,9) 2619 - │ │ │ ├── scan xy 2620 - │ │ │ │ ├── columns: x:1!null 2621 - │ │ │ │ └── key: (1) 2622 - │ │ │ ├── project 2623 - │ │ │ │ ├── columns: notnull:9!null k:3!null 2624 + │ │ ├── fd: (3)-->(9), (1)-->(3,9) 2625 + │ │ ├── scan xy 2626 + │ │ │ ├── columns: x:1!null 2627 + │ │ │ └── key: (1) 2628 + │ │ ├── project 2629 + │ │ │ ├── columns: notnull:9!null k:3!null 2630 + │ │ │ ├── key: (3) 2631 + │ │ │ ├── fd: (3)-->(9) 2632 + │ │ │ ├── select 2633 + │ │ │ │ ├── columns: k:3!null i:4 2634 │ │ │ │ ├── key: (3) 2635 - │ │ │ │ ├── fd: (3)-->(9) 2636 - │ │ │ │ ├── select 2637 + │ │ │ │ ├── fd: (3)-->(4) 2638 + │ │ │ │ ├── scan a 2639 │ │ │ │ │ ├── columns: k:3!null i:4 2640 │ │ │ │ │ ├── key: (3) 2641 - │ │ │ │ │ ├── fd: (3)-->(4) 2642 - │ │ │ │ │ ├── scan a 2643 - │ │ │ │ │ │ ├── columns: k:3!null i:4 2644 - │ │ │ │ │ │ ├── key: (3) 2645 - │ │ │ │ │ │ └── fd: (3)-->(4) 2646 - │ │ │ │ │ └── filters 2647 - │ │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2648 - │ │ │ │ └── projections 2649 - │ │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 2650 - │ │ │ └── filters 2651 - │ │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 2652 - │ │ └── aggregations 2653 - │ │ └── bool-or [as=bool_or:10, outer=(9)] 2654 - │ │ └── notnull:9 2655 - │ └── projections 2656 - │ └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=case:11, outer=(10)] 2657 + │ │ │ │ │ └── fd: (3)-->(4) 2658 + │ │ │ │ └── filters 2659 + │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2660 + │ │ │ └── projections 2661 + │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 2662 + │ │ └── filters 2663 + │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 2664 + │ └── aggregations 2665 + │ └── bool-or [as=bool_or:10, outer=(9)] 2666 + │ └── notnull:9 2667 └── projections 2668 - └── case:11 [as=r:8, outer=(11)] 2669 + └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=r:8, outer=(10)] 2670 -------------------------------------------------------------------------------- 2671 GenerateIndexScans (no changes) 2672 -------------------------------------------------------------------------------- 2673 -------------------------------------------------------------------------------- 2674 GenerateIndexScans (no changes) 2675 -------------------------------------------------------------------------------- 2676 -------------------------------------------------------------------------------- 2677 GenerateZigzagJoins (no changes) 2678 -------------------------------------------------------------------------------- 2679 -------------------------------------------------------------------------------- 2680 GenerateConstrainedScans (no changes) 2681 -------------------------------------------------------------------------------- 2682 -------------------------------------------------------------------------------- 2683 CommuteLeftJoin (higher cost) 2684 -------------------------------------------------------------------------------- 2685 project 2686 ├── columns: r:8 2687 ├── group-by 2688 │ ├── columns: x:1!null bool_or:10 2689 │ ├── grouping columns: x:1!null 2690 │ ├── key: (1) 2691 │ ├── fd: (1)-->(10) 2692 - │ ├── left-join (hash) 2693 + │ ├── right-join (hash) 2694 │ │ ├── columns: x:1!null k:3 notnull:9 2695 │ │ ├── key: (1) 2696 │ │ ├── fd: (3)-->(9), (1)-->(3,9) 2697 - │ │ ├── scan xy 2698 - │ │ │ ├── columns: x:1!null 2699 - │ │ │ └── key: (1) 2700 │ │ ├── project 2701 │ │ │ ├── columns: notnull:9!null k:3!null 2702 │ │ │ ├── key: (3) 2703 │ │ │ ├── fd: (3)-->(9) 2704 │ │ │ ├── select 2705 │ │ │ │ ├── columns: k:3!null i:4 2706 │ │ │ │ ├── key: (3) 2707 │ │ │ │ ├── fd: (3)-->(4) 2708 │ │ │ │ ├── scan a 2709 │ │ │ │ │ ├── columns: k:3!null i:4 2710 │ │ │ │ │ ├── key: (3) 2711 │ │ │ │ │ └── fd: (3)-->(4) 2712 │ │ │ │ └── filters 2713 │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2714 │ │ │ └── projections 2715 │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 2716 + │ │ ├── scan xy 2717 + │ │ │ ├── columns: x:1!null 2718 + │ │ │ └── key: (1) 2719 │ │ └── filters 2720 │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 2721 │ └── aggregations 2722 │ └── bool-or [as=bool_or:10, outer=(9)] 2723 │ └── notnull:9 2724 └── projections 2725 └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=r:8, outer=(10)] 2726 ================================================================================ 2727 GenerateMergeJoins 2728 Cost: 2200.10 2729 ================================================================================ 2730 project 2731 ├── columns: r:8 2732 ├── group-by 2733 │ ├── columns: x:1!null bool_or:10 2734 │ ├── grouping columns: x:1!null 2735 │ ├── key: (1) 2736 │ ├── fd: (1)-->(10) 2737 - │ ├── left-join (hash) 2738 + │ ├── left-join (merge) 2739 │ │ ├── columns: x:1!null k:3 notnull:9 2740 + │ │ ├── left ordering: +1 2741 + │ │ ├── right ordering: +3 2742 │ │ ├── key: (1) 2743 │ │ ├── fd: (3)-->(9), (1)-->(3,9) 2744 │ │ ├── scan xy 2745 │ │ │ ├── columns: x:1!null 2746 - │ │ │ └── key: (1) 2747 + │ │ │ ├── key: (1) 2748 + │ │ │ └── ordering: +1 2749 │ │ ├── project 2750 │ │ │ ├── columns: notnull:9!null k:3!null 2751 │ │ │ ├── key: (3) 2752 │ │ │ ├── fd: (3)-->(9) 2753 + │ │ │ ├── ordering: +3 2754 │ │ │ ├── select 2755 │ │ │ │ ├── columns: k:3!null i:4 2756 │ │ │ │ ├── key: (3) 2757 │ │ │ │ ├── fd: (3)-->(4) 2758 + │ │ │ │ ├── ordering: +3 2759 │ │ │ │ ├── scan a 2760 │ │ │ │ │ ├── columns: k:3!null i:4 2761 │ │ │ │ │ ├── key: (3) 2762 - │ │ │ │ │ └── fd: (3)-->(4) 2763 + │ │ │ │ │ ├── fd: (3)-->(4) 2764 + │ │ │ │ │ └── ordering: +3 2765 │ │ │ │ └── filters 2766 │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2767 │ │ │ └── projections 2768 │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 2769 - │ │ └── filters 2770 - │ │ └── k:3 = x:1 [outer=(1,3), constraints=(/1: (/NULL - ]; /3: (/NULL - ]), fd=(1)==(3), (3)==(1)] 2771 + │ │ └── filters (true) 2772 │ └── aggregations 2773 │ └── bool-or [as=bool_or:10, outer=(9)] 2774 │ └── notnull:9 2775 └── projections 2776 └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=r:8, outer=(10)] 2777 -------------------------------------------------------------------------------- 2778 GenerateMergeJoins (higher cost) 2779 -------------------------------------------------------------------------------- 2780 project 2781 ├── columns: r:8 2782 ├── group-by 2783 │ ├── columns: x:1!null bool_or:10 2784 │ ├── grouping columns: x:1!null 2785 │ ├── key: (1) 2786 │ ├── fd: (1)-->(10) 2787 - │ ├── left-join (merge) 2788 + │ ├── right-join (merge) 2789 │ │ ├── columns: x:1!null k:3 notnull:9 2790 - │ │ ├── left ordering: +1 2791 - │ │ ├── right ordering: +3 2792 + │ │ ├── left ordering: +3 2793 + │ │ ├── right ordering: +1 2794 │ │ ├── key: (1) 2795 │ │ ├── fd: (3)-->(9), (1)-->(3,9) 2796 - │ │ ├── scan xy 2797 - │ │ │ ├── columns: x:1!null 2798 - │ │ │ ├── key: (1) 2799 - │ │ │ └── ordering: +1 2800 │ │ ├── project 2801 │ │ │ ├── columns: notnull:9!null k:3!null 2802 │ │ │ ├── key: (3) 2803 │ │ │ ├── fd: (3)-->(9) 2804 │ │ │ ├── ordering: +3 2805 │ │ │ ├── select 2806 │ │ │ │ ├── columns: k:3!null i:4 2807 │ │ │ │ ├── key: (3) 2808 │ │ │ │ ├── fd: (3)-->(4) 2809 │ │ │ │ ├── ordering: +3 2810 │ │ │ │ ├── scan a 2811 │ │ │ │ │ ├── columns: k:3!null i:4 2812 │ │ │ │ │ ├── key: (3) 2813 │ │ │ │ │ ├── fd: (3)-->(4) 2814 │ │ │ │ │ └── ordering: +3 2815 │ │ │ │ └── filters 2816 │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2817 │ │ │ └── projections 2818 │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 2819 + │ │ ├── scan xy 2820 + │ │ │ ├── columns: x:1!null 2821 + │ │ │ ├── key: (1) 2822 + │ │ │ └── ordering: +1 2823 │ │ └── filters (true) 2824 │ └── aggregations 2825 │ └── bool-or [as=bool_or:10, outer=(9)] 2826 │ └── notnull:9 2827 └── projections 2828 └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=r:8, outer=(10)] 2829 ================================================================================ 2830 GenerateStreamingGroupBy 2831 Cost: 2190.10 2832 ================================================================================ 2833 project 2834 ├── columns: r:8 2835 ├── group-by 2836 │ ├── columns: x:1!null bool_or:10 2837 │ ├── grouping columns: x:1!null 2838 + │ ├── internal-ordering: +1 2839 │ ├── key: (1) 2840 │ ├── fd: (1)-->(10) 2841 │ ├── left-join (merge) 2842 │ │ ├── columns: x:1!null k:3 notnull:9 2843 │ │ ├── left ordering: +1 2844 │ │ ├── right ordering: +3 2845 │ │ ├── key: (1) 2846 │ │ ├── fd: (3)-->(9), (1)-->(3,9) 2847 + │ │ ├── ordering: +1 2848 │ │ ├── scan xy 2849 │ │ │ ├── columns: x:1!null 2850 │ │ │ ├── key: (1) 2851 │ │ │ └── ordering: +1 2852 │ │ ├── project 2853 │ │ │ ├── columns: notnull:9!null k:3!null 2854 │ │ │ ├── key: (3) 2855 │ │ │ ├── fd: (3)-->(9) 2856 │ │ │ ├── ordering: +3 2857 │ │ │ ├── select 2858 │ │ │ │ ├── columns: k:3!null i:4 2859 │ │ │ │ ├── key: (3) 2860 │ │ │ │ ├── fd: (3)-->(4) 2861 │ │ │ │ ├── ordering: +3 2862 │ │ │ │ ├── scan a 2863 │ │ │ │ │ ├── columns: k:3!null i:4 2864 │ │ │ │ │ ├── key: (3) 2865 │ │ │ │ │ ├── fd: (3)-->(4) 2866 │ │ │ │ │ └── ordering: +3 2867 │ │ │ │ └── filters 2868 │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2869 │ │ │ └── projections 2870 │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 2871 │ │ └── filters (true) 2872 │ └── aggregations 2873 │ └── bool-or [as=bool_or:10, outer=(9)] 2874 │ └── notnull:9 2875 └── projections 2876 └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=r:8, outer=(10)] 2877 ================================================================================ 2878 Final best expression 2879 Cost: 2190.10 2880 ================================================================================ 2881 project 2882 ├── columns: r:8 2883 ├── group-by 2884 │ ├── columns: x:1!null bool_or:10 2885 │ ├── grouping columns: x:1!null 2886 │ ├── internal-ordering: +1 2887 │ ├── key: (1) 2888 │ ├── fd: (1)-->(10) 2889 │ ├── left-join (merge) 2890 │ │ ├── columns: x:1!null k:3 notnull:9 2891 │ │ ├── left ordering: +1 2892 │ │ ├── right ordering: +3 2893 │ │ ├── key: (1) 2894 │ │ ├── fd: (3)-->(9), (1)-->(3,9) 2895 │ │ ├── ordering: +1 2896 │ │ ├── scan xy 2897 │ │ │ ├── columns: x:1!null 2898 │ │ │ ├── key: (1) 2899 │ │ │ └── ordering: +1 2900 │ │ ├── project 2901 │ │ │ ├── columns: notnull:9!null k:3!null 2902 │ │ │ ├── key: (3) 2903 │ │ │ ├── fd: (3)-->(9) 2904 │ │ │ ├── ordering: +3 2905 │ │ │ ├── select 2906 │ │ │ │ ├── columns: k:3!null i:4 2907 │ │ │ │ ├── key: (3) 2908 │ │ │ │ ├── fd: (3)-->(4) 2909 │ │ │ │ ├── ordering: +3 2910 │ │ │ │ ├── scan a 2911 │ │ │ │ │ ├── columns: k:3!null i:4 2912 │ │ │ │ │ ├── key: (3) 2913 │ │ │ │ │ ├── fd: (3)-->(4) 2914 │ │ │ │ │ └── ordering: +3 2915 │ │ │ │ └── filters 2916 │ │ │ │ └── (i:4 = 5) IS NOT false [outer=(4)] 2917 │ │ │ └── projections 2918 │ │ │ └── i:4 IS NOT NULL [as=notnull:9, outer=(4)] 2919 │ │ └── filters (true) 2920 │ └── aggregations 2921 │ └── bool-or [as=bool_or:10, outer=(9)] 2922 │ └── notnull:9 2923 └── projections 2924 └── CASE WHEN bool_or:10 THEN true WHEN bool_or:10 IS NULL THEN false END [as=r:8, outer=(10)]