New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for JOIN algorithm hints #15807
Labels
Projects
Milestone
Comments
It could be useful to be able to turn off the generation of hints, especially when translating between dialects: |
lukaseder
added a commit
that referenced
this issue
Nov 8, 2023
This includes: - QOM API implementation - DSL API implementation on Table - DSL API implementation on SelectJoinStep - CRDB and SQL Server implementation
lukaseder
added
E: Professional Edition
E: Enterprise Edition
and removed
E: All Editions
E: Professional Edition
E: Enterprise Edition
labels
Nov 8, 2023
Only commercial RDBMS support this feature natively with a T-SQL style syntax. For the only OSS RDBMS where join hints are supported (MySQL), we'll need the commercial |
lukaseder
added a commit
that referenced
this issue
Nov 8, 2023
lukaseder
added a commit
that referenced
this issue
Nov 8, 2023
lukaseder
added a commit
that referenced
this issue
Nov 9, 2023
lukaseder
added a commit
that referenced
this issue
Nov 9, 2023
lukaseder
added a commit
that referenced
this issue
Nov 9, 2023
This was referenced Nov 9, 2023
This was referenced Nov 9, 2023
Implemented in jOOQ 3.19. Some additional follow-up work includes: |
2 tasks
lukaseder
added a commit
that referenced
this issue
Nov 9, 2023
lukaseder
added a commit
that referenced
this issue
Nov 9, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Customers have often requested better support for
JOIN
algorithm hints, i.e. hints that force an optimiser to choose nested loop joins, hash joins, merge joins, etc.The syntax is always vendor specific:
The SQL standard is impartial to such implementation details. The canonical approach would be to support all of these directly as API, such as:
But this would heavy on the new API that would have to be repeated:
Table
and inSelectJoinStep
NATURAL
flag)JOIN
algorithmI.e. we'd get dozens of additional methods for something that is rarely useful.
Other API designs are possible, for example, we could have:
enum
that can be passed to eachJOIN
method, e.g.BOOK.rightJoin(AUTHOR, HASH)
(this conflicts with the existing method that allows for dynamic join types, i.e.BOOK.join(AUTHOR, RIGHT_JOIN)
JOIN
types, e.g.BOOK.rightJoin(AUTHOR).withHash()
Table.with()
SelectJoinStep
APIJOIN
types, e.g.BOOK.hash().rightJoin(AUTHOR)
hash()
, etc.) with again all theJOIN
methods repeated, as well as transient implementation type that remembers the table and delays construction of theJoin
implementationTable
API, which may conflict with future featuresSelectJoinStep
APITable
andSelectJoinStep
as suggested above, e.g.BOOK.rightHashJoin(AUTHOR)
crossJoin()
orcrossApply()
)straightJoin()
method from MySQLGiven the benefits of dynamic SQL, there's certainly going to be
BOOK.join(AUTHOR, RIGHT_JOIN, HASH)
, where both are combinedImplementation
Hints are vendor specific. Some hints are probably supported by most vendors who support hints at all, including e.g.:
HASH
LOOP
MERGE
Other hints are vendor specific, such as:
NO_HASH
(this just reduces the possible choices, but doesn't limit it to a specific choice)REMOTE
The strategy will be to ignore a hint if we don't know it is supported by a dialect.
Tasks
Table
SelectJoinStep
SelectQuery
APIQOM
APIa LEFT LOOP JOIN b
)Oracle style comment hints (e.g.Postponed: Support parsing Oracle / YugabyteDB style JOIN hints #15812/*+USE_NL(a b)*/
).<dialects/>
translation)Supported hint types:
HASH
LOOP
MERGE
Not supported (yet):
NATURAL
join (they're possible via the dynamic SQL DSL overload)NO_HASH
,NO_LOOP
,NO_MERGE
, i.e. hints excluding a certain algorithmINVERTED
(to enforceGIN
index lookups in CockroachDB)REMOTE
(to enforce the "driving site" of a nested loop join in SQL Server)Dialect support:
directives-that-can-alter-query-plan
Not yet implemented (see #15811)
Not applicable
HASH_JOIN
hint has been removed again in 8.0.20, and I can't seem to use the others to force MySQL to do a hash join...)The text was updated successfully, but these errors were encountered: