Skip to content

planner: selection splits the join group to two parts, forbidding join reorder to get best order #59972

@qw4990

Description

@qw4990

Enhancement

See the case below, the best join order is joining t1 and t2 first, but both our join-order and leading can't support it:

create table t1(id int not null primary key,name varchar(100));
create table t2 like t1;
create table t3 like t1;
create table t4 like t1;
explain select /*+ leading(t1, t2) */ * from t1 inner join t3 on t1.id=t3.id left join t4 on t4.id=t3.id join t2 on t1.id=t2.id where t3.name like 'test3' or t4.name like 'test4';

The root cause is that the predicate t3 like or t4 like splits the whole query into 2 join groups, and both our join-order and leading can't support changing join orders of 2 tables across 2 different join groups:

Image

One solution might be we can pull this predicate up first, and then we can merge these 2 join groups in to 1 and join t1 and t2 first:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions