Allow hints around the type and order of JOIN operations #13283
Labels
complexity: no estimate
feature: performance
feature: sql: joins
need refined description
A maintainer should refine the description and clarify the scope
Problem Statement
[Raising feature request for consideration/refinement following a brief discussion with @seut ]
In some cases, the optimizer may come out with a suboptimal plan for performing JOINs for a query.
There may be many reasons for this, but on an exceptional basis, knowing how the data looks like, it would be useful to be able to request a specific JOIN order or force a hash join.
Possible Solutions
Something along the lines of what other systems do:
PostgreSQL allows hinting
NestLoop
andMergeJoin
withpg_hint_plan
.In MySQL order can be forced using the keyword
STRAIGHT_JOIN
instead ofJOIN
.In MSSQL
JOIN
can be preceded withLOOP
(for nested loops),MERGE
, orHASH
to request a specific mechanism.In Oracle the optimizer looks for hints within
/* */
comments and there are hints such asUSE_NL
to request nested loops.Considered Alternatives
Try rewriting queries with subqueries until obtaining the desired plan, results may change when upgrading CrateDB or changing other factors in the environment.
References:
MS SQL Server Hints https://learn.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-query?view=sql-server-ver16#force-order
The text was updated successfully, but these errors were encountered: