You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
recreate table t1 (id intprimary key, col int);
createindext1_colon t1 (col);
recreate table t2 (id intprimary key, col int);
createindext2_colon t2 (col);
recreate table t3 (id intprimary key, col int);
createindext3_colon t3 (col);
Test case:
select*from t1 t1
inner join t2 t2 ont1.id=t2.idinner join t3 t3 ont1.id=t3.idwheret1.col=0andt2.col=0andt3.col=0;
-- PLAN JOIN (T1 INDEX (T1_COL), T2 INDEX (RDB$PRIMARY11), T3 INDEX (RDB$PRIMARY12))select*from t1 t1
inner join t2 t2 ont1.id=t2.idinner join t3 t3 ont2.id=t3.idwheret1.col=0andt2.col=0andt3.col=0;
-- PLAN JOIN (T1 INDEX (T1_COL), T2 INDEX (RDB$PRIMARY11), T3 INDEX (RDB$PRIMARY12))select*from t1 t1
inner join t2 t2 ont1.id=t2.idinner join t3 t3 ont1.id=t3.idandt2.id=t3.idwheret1.col=0andt2.col=0andt3.col=0;
-- PLAN JOIN (T1 INDEX (T1_COL), T2 INDEX (RDB$PRIMARY11), T3 INDEX (RDB$PRIMARY12))select*from t1 t1
inner join t2 t2 using (id)
inner join t3 t3 using (id)
wheret1.col=0andt2.col=0andt3.col=0;
-- PLAN HASH (JOIN (T1 INDEX (T1_COL), T2 INDEX (RDB$PRIMARY11)), T3 INDEX (T3_COL))
The last query with USING syntax gets a different (usually worse) plan. This issue is closely related to #3357, because using (id) is internally transformed into coalesce(t1.id, t2.id) = t3.id. But I intentionally create a separate ticket, because the JOIN .. USING case is more widely used and most people are unaware of the aforementioned transformation.
Of course, the issue does not exist for only two tables joined, or if the matching column names are unique for the every join part.
The text was updated successfully, but these errors were encountered:
DDL:
Test case:
The last query with USING syntax gets a different (usually worse) plan. This issue is closely related to #3357, because
using (id)
is internally transformed intocoalesce(t1.id, t2.id) = t3.id
. But I intentionally create a separate ticket, because the JOIN .. USING case is more widely used and most people are unaware of the aforementioned transformation.Of course, the issue does not exist for only two tables joined, or if the matching column names are unique for the every join part.
The text was updated successfully, but these errors were encountered: