Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions enginetest/join_planning_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,20 @@ var JoinPlanningTests = []joinPlanScript{
"CREATE table ab (a int primary key, b int);",
"insert into xy values (1,0), (2,1), (0,2), (3,3);",
"insert into ab values (0,2), (1,2), (2,2), (3,1);",
`analyze table xy update histogram on x using data '{"row_count":1000}'`,
`analyze table ab update histogram on a using data '{"row_count":1000}'`,
`analyze table xy update histogram on x using data '{"row_count":1000000}'`,
`analyze table ab update histogram on a using data '{"row_count":1000000}'`,
},
tests: []JoinPlanTest{
{
q: "select /*+ JOIN_ORDER(ab, xy) MERGE_JOIN(ab, xy)*/ * from ab join xy on y = a order by 1, 3",
types: []plan.JoinType{plan.JoinTypeMerge},
exp: []sql.Row{{0, 2, 1, 0}, {1, 2, 2, 1}, {2, 2, 0, 2}, {3, 1, 3, 3}},
},
{
q: "select * from ab join xy on x = a and y = a order by 1, 3",
types: []plan.JoinType{plan.JoinTypeMerge},
exp: []sql.Row{{3, 1, 3, 3}},
},
{
q: "set @@SESSION.disable_merge_join = 1",
exp: []sql.Row{{}},
Expand All @@ -105,6 +110,11 @@ var JoinPlanningTests = []joinPlanScript{
types: []plan.JoinType{plan.JoinTypeLookup},
exp: []sql.Row{{0, 2, 1, 0}, {1, 2, 2, 1}, {2, 2, 0, 2}, {3, 1, 3, 3}},
},
{
q: "select * from ab join xy on x = a and y = a order by 1, 3",
types: []plan.JoinType{plan.JoinTypeLookup},
exp: []sql.Row{{3, 1, 3, 3}},
},
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion sql/memo/select_hints.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ type joinHints struct {
}

func (h joinHints) isEmpty() bool {
return len(h.ops) == 0 && h.order == nil && !h.leftDeep
return len(h.ops) == 0 && h.order == nil && !h.leftDeep && len(h.block) == 0
}

// satisfiedBy returns whether a RelExpr satisfies every join hint. This
Expand Down