#20181·jOOQ

Implicit path join elimination doesn't happen with many-to-many relationships when the unnecessary parent table is in a one-to-one relationship with a child table

Author: lukasederCreated Sep 7, 2026Updated Sep 7, 2026
LabelsT: DefectC: FunctionalityP: MediumE: All Editions

Related to:

With an esoteric schema like this:

sql
create table mm_elim_onetoone_a (a int not null primary key);
create table mm_elim_onetoone_c (c int not null primary key);

create table mm_elim_onetoone_ab (
  a int not null references mm_elim_onetoone_a,
  b int not null unique,
  primary key (a, b)
);
create table mm_elim_onetoone_bc (
  b int not null unique,
  c int not null references mm_elim_onetoone_c,
  primary key (b, c)
);

create table mm_elim_onetoone_b (
  b int not null primary key references mm_elim_onetoone_ab (b) references mm_elim_onetoone_bc (b)
);

We'd expect a query like this:

java
ctx.select(
        MM_ELIM_ONETOONE_A.A,
        MM_ELIM_ONETOONE_A.mmElimOnetooneB().mmElimOnetooneC().C)
   .from(MM_ELIM_ONETOONE_A)

To have its unnecessary JOIN of the table B eliminated, as B is in a one-to-one relationship with both AB and AC. Yet, this is not the case:

sql
select "MM_ELIM_ONETOONE_A"."A", "alias_102858269"."C"
from (
  "MM_ELIM_ONETOONE_A"
    left outer join (
      "MM_ELIM_ONETOONE_AB" "alias_90804208"
        left outer join (
          "MM_ELIM_ONETOONE_B" "alias_130018667" -- B is right here
            join (
              "MM_ELIM_ONETOONE_BC" "alias_107903838"
                join "MM_ELIM_ONETOONE_C" "alias_102858269"
                  on "alias_107903838"."C" = "alias_102858269"."C"
            )
              on "alias_130018667"."B" = "alias_107903838"."B"
        )
          on "alias_130018667"."B" = "alias_90804208"."B"
    )
      on "alias_90804208"."A" = "MM_ELIM_ONETOONE_A"."A"
  )