Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB_KEY based join of two tables may be ineffective [CORE4530] #4848

Closed
firebird-automations opened this issue Aug 25, 2014 · 9 comments
Closed

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @pavel-zotov

Is related to CORE1295
Is related to QA612

Simplified test case:

recreate table t (id int primary key);
commit;
set planonly;

select count(*)
from (select id, rdb$db_key k from t a order by id) x
left join t z on x.k = z.rdb$db_key -- (*)

PLAN JOIN (X A ORDER RDB$PRIMARY4, Z NATURAL)

vs

select count(*)
from (select id, rdb$db_key k from t a order by id) x
left join t z on z.rdb$db_key = x.k -- (*)

PLAN JOIN (X A ORDER RDB$PRIMARY4, Z INDEX ())

i.e. order of expressions in the join condition affects the generated plan and thus performance.

Commits: 76c9ea1 182390b FirebirdSQL/fbt-repository@85c003c FirebirdSQL/fbt-repository@5dade31

====== Test Details ======

See also: CORE4038, CORE4492

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Link: This issue is related to CORE1295 [ CORE1295 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

reporter: Dmitry Yemanov [ dimitr ] => Pavel Zotov [ tabloid ]

assignee: Dmitry Yemanov [ dimitr ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @doychin

This can also be ported back to 2.1.x version. It is the same situation there to.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

description: Simplified test case:

set planonly;
recreate table t (id int primary key);
commit;

select count(*)
from (select id, rdb$db_key k from t a order by id) x
left join t z on x.k = z.rdb$db_key -- (*)

PLAN JOIN (X A ORDER RDB$PRIMARY4, Z NATURAL)

vs

select count(*)
from (select id, rdb$db_key k from t a order by id) x
left join t z on z.rdb$db_key = x.k -- (*)

PLAN JOIN (X A ORDER RDB$PRIMARY4, Z INDEX ())

i.e. order of expressions in the join condition affects the generated plan and thus performance.

=>

Simplified test case:

recreate table t (id int primary key);
commit;
set planonly;

select count(*)
from (select id, rdb$db_key k from t a order by id) x
left join t z on x.k = z.rdb$db_key -- (*)

PLAN JOIN (X A ORDER RDB$PRIMARY4, Z NATURAL)

vs

select count(*)
from (select id, rdb$db_key k from t a order by id) x
left join t z on z.rdb$db_key = x.k -- (*)

PLAN JOIN (X A ORDER RDB$PRIMARY4, Z INDEX ())

i.e. order of expressions in the join condition affects the generated plan and thus performance.

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

Most probably, there will be no 2.1.x releases anymore, so it's out of question.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 3.0 Beta 1 [ 10332 ]

Fix Version: 2.5.4 [ 10585 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Resolved [ 5 ]

QA Status: Done successfully

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Resolved [ 5 ]

Test Details: See also: CORE4038, CORE4492

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Link: This issue is related to QA612 [ QA612 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment