Skip to content

Commit

Permalink
sql: specify hash or merge join in EXPLAIN
Browse files Browse the repository at this point in the history
Replace `join` with `hash-join` or `merge-join` in `EXPLAIN` output.

Fixes cockroachdb#35683.

Release note (sql change): EXPLAIN tree now uses `hash-join` or
`merge-join` instead of `join`.
  • Loading branch information
RaduBerinde committed Mar 13, 2019
1 parent 8f3251b commit fdec322
Show file tree
Hide file tree
Showing 27 changed files with 1,060 additions and 1,054 deletions.
16 changes: 8 additions & 8 deletions pkg/sql/logictest/testdata/planner_test/aggregate
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ group · ·
│ scalar · · ·
└── render · · ("((k, v, w, s) AS k, v, w, s)") ·
│ render 0 ((a.k, a.v, a.w, a.s) AS k, v, w, s) · ·
└── join · · (k, v, w, s, k[omitted], v[omitted], w[omitted], s[omitted]) ·
└── hash-join · · (k, v, w, s, k[omitted], v[omitted], w[omitted], s[omitted]) ·
│ type cross · ·
├── scan · · (k, v, w, s) k!=NULL; key(k)
│ table kv@primary · ·
Expand All @@ -103,7 +103,7 @@ group · ·
│ render 2 a.w
│ render 3 a.s
│ render 4 b.k
└── join · ·
└── hash-join · ·
│ type cross
├── scan · ·
│ table kv@primary
Expand All @@ -127,7 +127,7 @@ group · ·
│ render 3 a.w
│ render 4 a.s
│ render 5 b.k
└── join · ·
└── hash-join · ·
│ type cross
├── scan · ·
│ table kv@primary
Expand All @@ -151,7 +151,7 @@ group · ·
│ render 2 a.w
│ render 3 a.s
│ render 4 b.k
└── join · ·
└── hash-join · ·
│ type cross
├── scan · ·
│ table kv@primary
Expand All @@ -174,7 +174,7 @@ group · ·
│ render 1 a.v
│ render 2 a.w
│ render 3 a.s
└── join · ·
└── hash-join · ·
│ type cross
├── scan · ·
│ table kv@primary
Expand Down Expand Up @@ -626,7 +626,7 @@ group · ·
│ render 2 test.public.kv.w
│ render 3 test.public.kv.s
│ render 4 test.public.abc.d
└── join · ·
└── hash-join · ·
│ type inner
│ pred test.public.kv.k >= test.public.abc.d
├── scan · ·
Expand Down Expand Up @@ -738,7 +738,7 @@ render · ·
│ render 1 test.public.ab.a
│ render 2 test.public.ab.b
│ render 3 test.public.xy.y
└── join · ·
└── hash-join · ·
│ type cross
├── scan · ·
│ table ab@primary
Expand Down Expand Up @@ -853,7 +853,7 @@ group · · (z, max)
query TTTTT
EXPLAIN (VERBOSE) SELECT * FROM (SELECT x, max(y) FROM group_ord GROUP BY x) JOIN (SELECT z, min(y) FROM group_ord@foo GROUP BY z) ON x = z
----
join · · (x, max, z, min) x=z; x!=NULL
merge-join · · (x, max, z, min) x=z; x!=NULL
│ type inner · ·
│ equality (x) = (z) · ·
│ mergeJoinOrder +"(x=z)" · ·
Expand Down
52 changes: 26 additions & 26 deletions pkg/sql/logictest/testdata/planner_test/distsql_interleaved_join
Original file line number Diff line number Diff line change
Expand Up @@ -254,20 +254,20 @@ EXPLAIN SELECT * FROM grandchild2 JOIN parent1 USING(pid1) WHERE
OR pid1 >= 19 AND pid1 <= 21
OR pid1 >= 31 AND pid1 <= 33
----
render · ·
└── join · ·
│ type inner
│ equality (pid1) = (pid1)
│ mergeJoinOrder +"(pid1=pid1)"
├── scan · ·
│ table grandchild2@primary
│ spans /11/#/56/1-/13/#/56/2 /19/#/56/1-/21/#/56/2 /31/#/56/1-/33/#/56/2
│ filter ((pid1 <= 13) OR ((pid1 >= 19) AND (pid1 <= 21))) OR (pid1 >= 31)
└── scan · ·
· table parent1@primary
· spans /11-/13/# /19-/21/# /31-/33/#
· parallel ·
· filter ((pid1 <= 13) OR ((pid1 >= 19) AND (pid1 <= 21))) OR (pid1 >= 31)
render · ·
└── merge-join · ·
type inner
equality (pid1) = (pid1)
mergeJoinOrder +"(pid1=pid1)"
├── scan · ·
table grandchild2@primary
spans /11/#/56/1-/13/#/56/2 /19/#/56/1-/21/#/56/2 /31/#/56/1-/33/#/56/2
filter ((pid1 <= 13) OR ((pid1 >= 19) AND (pid1 <= 21))) OR (pid1 >= 31)
└── scan · ·
· table parent1@primary
· spans /11-/13/# /19-/21/# /31-/33/#
· parallel ·
· filter ((pid1 <= 13) OR ((pid1 >= 19) AND (pid1 <= 21))) OR (pid1 >= 31)

# Join on multiple interleaved columns with an overarching ancestor (parent1).
# Note there are 5 nodes because the filter cid2 >= 12 AND cid2 <= 14
Expand Down Expand Up @@ -297,17 +297,17 @@ EXPLAIN
OR child2.cid2 >= 12 AND child2.cid2 <= 14
OR gcid2 >= 49 AND gcid2 <= 51
----
join · ·
│ type inner
│ equality (pid1, cid2, cid3) = (pid1, cid2, cid3)
│ mergeJoinOrder +"(pid1=pid1)",+"(cid2=cid2)",+"(cid3=cid3)"
├── scan · ·
│ table child2@primary
│ spans ALL
└── scan · ·
· table grandchild2@primary
· spans ALL
· filter (((pid1 >= 5) AND (pid1 <= 7)) OR ((cid2 >= 12) AND (cid2 <= 14))) OR ((gcid2 >= 49) AND (gcid2 <= 51))
merge-join · ·
type inner
equality (pid1, cid2, cid3) = (pid1, cid2, cid3)
mergeJoinOrder +"(pid1=pid1)",+"(cid2=cid2)",+"(cid3=cid3)"
├── scan · ·
table child2@primary
spans ALL
└── scan · ·
· table grandchild2@primary
· spans ALL
· filter (((pid1 >= 5) AND (pid1 <= 7)) OR ((cid2 >= 12) AND (cid2 <= 14))) OR ((gcid2 >= 49) AND (gcid2 <= 51))

# Aggregation over parent and child keys.
query T
Expand Down Expand Up @@ -449,7 +449,7 @@ query TTT
EXPLAIN SELECT * FROM parent1 JOIN (SELECT * FROM child1 ORDER BY cid1) USING (pid1)
----
render · ·
└── join · ·
└── hash-join · ·
│ type inner
│ equality (pid1) = (pid1)
├── scan · ·
Expand Down
12 changes: 6 additions & 6 deletions pkg/sql/logictest/testdata/planner_test/distsql_join
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ EXPLAIN (VERBOSE) (SELECT * FROM (SELECT a,b FROM data) NATURAL JOIN (SELECT a,b
render · · (a, b) a!=NULL; b!=NULL
│ render 0 a · ·
│ render 1 b · ·
└── join · · (a, b, a[omitted], b[omitted]) a=a; b=b; a!=NULL; b!=NULL
└── merge-join · · (a, b, a[omitted], b[omitted]) a=a; b=b; a!=NULL; b!=NULL
│ type inner · ·
│ equality (a, b) = (a, b) · ·
│ mergeJoinOrder +"(a=a)",+"(b=b)" · ·
Expand All @@ -61,7 +61,7 @@ render · · (a, b)
query TTTTT
EXPLAIN (VERBOSE) (SELECT * FROM (SELECT a,b FROM data AS data1) JOIN (SELECT c,d FROM data AS data2 ORDER BY c,d) ON a=c AND b=d ORDER BY c,d)
----
join · · (a, b, c, d) a=c; b=d; a!=NULL; b!=NULL; +a,+b
merge-join · · (a, b, c, d) a=c; b=d; a!=NULL; b!=NULL; +a,+b
│ type inner · ·
│ equality (a, b) = (c, d) · ·
│ mergeJoinOrder +"(a=c)",+"(b=d)" · ·
Expand Down Expand Up @@ -90,7 +90,7 @@ https://cockroachdb.github.io/distsqlplan/decode.html#eJzEll9ro0wUxu_fTyHn6l06oj
query TTTTT
EXPLAIN (VERBOSE) (SELECT * FROM (SELECT a,b FROM data AS data1) JOIN (SELECT c,d FROM data AS data2 ORDER BY c,d) ON a=c AND b=d ORDER BY a,b)
----
join · · (a, b, c, d) a=c; b=d; a!=NULL; b!=NULL; +a,+b
merge-join · · (a, b, c, d) a=c; b=d; a!=NULL; b!=NULL; +a,+b
│ type inner · ·
│ equality (a, b) = (c, d) · ·
│ mergeJoinOrder +"(a=c)",+"(b=d)" · ·
Expand Down Expand Up @@ -120,7 +120,7 @@ EXPLAIN (VERBOSE) (SELECT * FROM (SELECT a,b FROM data AS data1) JOIN (SELECT c,
----
sort · · (a, b, c, d) a=c; b=d; a!=NULL; b!=NULL; +b,+a
│ order +b,+a · ·
└── join · · (a, b, c, d) a=c; b=d; a!=NULL; b!=NULL
└── merge-join · · (a, b, c, d) a=c; b=d; a!=NULL; b!=NULL
│ type inner · ·
│ equality (a, b) = (c, d) · ·
│ mergeJoinOrder +"(a=c)",+"(b=d)" · ·
Expand Down Expand Up @@ -169,14 +169,14 @@ EXPLAIN (VERBOSE) (SELECT a,b from data AS data3 NATURAL JOIN ((SELECT a,b FROM
render · · (a, b) a!=NULL; b!=NULL
│ render 0 data3.a · ·
│ render 1 data3.b · ·
└── join · · (a, b, c[omitted], d[omitted], a[omitted], b[omitted], c[omitted], d[omitted]) a=c=a=c; b=d=b=d; a!=NULL; b!=NULL
└── merge-join · · (a, b, c[omitted], d[omitted], a[omitted], b[omitted], c[omitted], d[omitted]) a=c=a=c; b=d=b=d; a!=NULL; b!=NULL
│ type inner · ·
│ equality (a, b, c, d) = (a, b, c, d) · ·
│ mergeJoinOrder +"(a=a)",+"(b=b)",+"(c=c)",+"(d=d)" · ·
├── scan · · (a, b, c, d) a!=NULL; b!=NULL; c!=NULL; d!=NULL; key(a,b,c,d); +a,+b,+c,+d
│ table data@primary · ·
│ spans ALL · ·
└── join · · (a, b, c, d) a=c; b=d; a!=NULL; b!=NULL; +a,+b
└── merge-join · · (a, b, c, d) a=c; b=d; a!=NULL; b!=NULL; +a,+b
│ type inner · ·
│ equality (a, b) = (c, d) · ·
│ mergeJoinOrder +"(a=c)",+"(b=d)" · ·
Expand Down
30 changes: 15 additions & 15 deletions pkg/sql/logictest/testdata/planner_test/distsql_numtables
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,21 @@ https://cockroachdb.github.io/distsqlplan/decode.html#eJy8lU2L2zAQhu_9FWFOu6AQS7
query TTTTT
EXPLAIN (VERBOSE) SELECT x, str FROM NumToSquare JOIN NumToStr ON x = y WHERE x % 2 = 0
----
render · · (x, str) x!=NULL; key(x)
│ render 0 test.public.numtosquare.x · ·
│ render 1 test.public.numtostr.str · ·
└── join · · (x, xsquared[omitted], y[omitted], str) x=y; x!=NULL; key(x)
│ type inner · ·
│ equality (x) = (y) · ·
│ mergeJoinOrder +"(x=y)" · ·
├── scan · · (x, xsquared[omitted]) x!=NULL; key(x); +x
│ table numtosquare@primary · ·
│ spans ALL · ·
│ filter (x % 2) = 0 · ·
└── scan · · (y, str) y!=NULL; key(y); +y
· table numtostr@primary · ·
· spans ALL · ·
· filter (y % 2) = 0 · ·
render · · (x, str) x!=NULL; key(x)
render 0 test.public.numtosquare.x · ·
render 1 test.public.numtostr.str · ·
└── merge-join · · (x, xsquared[omitted], y[omitted], str) x=y; x!=NULL; key(x)
type inner · ·
equality (x) = (y) · ·
mergeJoinOrder +"(x=y)" · ·
├── scan · · (x, xsquared[omitted]) x!=NULL; key(x); +x
table numtosquare@primary · ·
spans ALL · ·
filter (x % 2) = 0 · ·
└── scan · · (y, str) y!=NULL; key(y); +y
· table numtostr@primary · ·
· spans ALL · ·
· filter (y % 2) = 0 · ·

query T
SELECT url FROM [EXPLAIN (DISTSQL) SELECT x, str FROM NumToSquare JOIN NumToStr ON x = y WHERE x % 2 = 0]
Expand Down
Loading

0 comments on commit fdec322

Please sign in to comment.