github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/opt/exec/execbuilder/testdata/join_order (about) 1 # LogicTest: local 2 3 statement ok 4 CREATE TABLE bx ( 5 b INT PRIMARY KEY, 6 x INT 7 ) 8 9 statement ok 10 CREATE TABLE cy ( 11 c INT PRIMARY KEY, 12 y INT 13 ) 14 15 statement ok 16 CREATE TABLE dz ( 17 d INT PRIMARY KEY, 18 z INT 19 ) 20 21 statement ok 22 CREATE TABLE abc ( 23 a INT PRIMARY KEY, 24 b INT, 25 c INT, 26 d INT, 27 FAMILY (a, b, c, d) 28 ) 29 30 statement ok 31 SET reorder_joins_limit = 0 32 33 statement error cannot set.*negative value 34 SET CLUSTER SETTING sql.defaults.reorder_joins_limit = -1 35 36 query TTTTT 37 EXPLAIN (VERBOSE) SELECT * FROM abc, bx, cy WHERE a = 1 AND abc.b = bx.b AND abc.c = cy.c 38 ---- 39 · distributed false · · 40 · vectorized true · · 41 render · · (a, b, c, d, b, x, c, y) · 42 │ render 0 a · · 43 │ render 1 b · · 44 │ render 2 c · · 45 │ render 3 d · · 46 │ render 4 b · · 47 │ render 5 x · · 48 │ render 6 c · · 49 │ render 7 y · · 50 └── hash-join · · (b, x, c, y, a, b, c, d) · 51 │ type inner · · 52 │ equality (b, c) = (b, c) · · 53 │ left cols are key · · · 54 │ right cols are key · · · 55 ├── cross-join · · (b, x, c, y) · 56 │ │ type cross · · 57 │ ├── scan · · (b, x) · 58 │ │ table bx@primary · · 59 │ │ spans FULL SCAN · · 60 │ └── scan · · (c, y) · 61 │ table cy@primary · · 62 │ spans FULL SCAN · · 63 └── scan · · (a, b, c, d) · 64 · table abc@primary · · 65 · spans /1-/1/# · · 66 67 statement ok 68 SET reorder_joins_limit = 3 69 70 query TTTTT 71 EXPLAIN (VERBOSE) SELECT * FROM abc, bx, cy WHERE a = 1 AND abc.b = bx.b AND abc.c = cy.c 72 ---- 73 · distributed false · · 74 · vectorized true · · 75 render · · (a, b, c, d, b, x, c, y) · 76 │ render 0 a · · 77 │ render 1 b · · 78 │ render 2 c · · 79 │ render 3 d · · 80 │ render 4 b · · 81 │ render 5 x · · 82 │ render 6 c · · 83 │ render 7 y · · 84 └── lookup-join · · (a, b, c, d, c, y, b, x) · 85 │ table bx@primary · · 86 │ type inner · · 87 │ equality (b) = (b) · · 88 │ equality cols are key · · · 89 │ parallel · · · 90 └── lookup-join · · (a, b, c, d, c, y) · 91 │ table cy@primary · · 92 │ type inner · · 93 │ equality (c) = (c) · · 94 │ equality cols are key · · · 95 │ parallel · · · 96 └── scan · · (a, b, c, d) · 97 · table abc@primary · · 98 · spans /1-/1/# · ·