gpdb icon indicating copy to clipboard operation
gpdb copied to clipboard

[ORCA] Support left/right outer join order hints

Open dgkimura opened this issue 1 year ago • 6 comments

Commit https://github.com/greenplum-db/gpdb/commit/ef7eec414877eb274e8c4351a2ef425139174d56 added a framework to support inner join order hints.

This commit extends that framework to support left (LOJ) and right (ROJ) outer joins. LOJ and ROJ have the following additional restrictions:

  1. Join predicates are non-transitive. For example:

    SELECT * FROM t1 LEFT JOIN t2 ON t1.a=42 LEFT JOIN t3 ON t1.a>4;

    Predicates a=42 and a>4 cannot be pushed below their respective join conditions. Otherwise NULL values may not be output correctly.

  2. Join kind (e.g. left, right) is affected by the order. For example:

    SELECT * FROM t1 LEFT JOIN t2 ON t1.a=42;

    Leading((t1 t2)) requires a left join Leading((t2 t1)) requires a right join

CLogicalNAryJoin stores the necesary information to handle these restrictions inside CScalarNAryJoinPredList.


Dev-pipeline: https://dev.ci.gpdb.pivotal.io/teams/main/pipelines/gpdb-dev-orca-join-hints-LOJ-rocky8

dgkimura avatar Apr 16 '24 00:04 dgkimura