Issue Details (XML | Word | Printable)

Key: CORE-4530
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Dmitry Yemanov
Reporter: Pavel Zotov
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Firebird Core

DB_KEY based join of two tables may be ineffective

Created: 25/Aug/14 01:24 PM   Updated: 25/Sep/15 01:13 PM
Component/s: Engine
Affects Version/s: 3.0 Alpha 2, 2.5.3
Fix Version/s: 3.0 Beta 1, 2.5.4

Issue Links:
Relate
 

QA Status: Done successfully
Test Details: See also: CORE-4038, CORE-4492


 Description  « Hide
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.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Dmitry Yemanov made changes - 25/Aug/14 01:25 PM
Field Original Value New Value
Link This issue is related to CORE-1295 [ CORE-1295 ]
Dmitry Yemanov made changes - 25/Aug/14 01:25 PM
Assignee Dmitry Yemanov [ dimitr ]
Reporter Dmitry Yemanov [ dimitr ] Pavel Zotov [ tabloid ]
Doychin Bondzhev added a comment - 25/Aug/14 01:32 PM
This can also be ported back to 2.1.x version. It is the same situation there to.

Dmitry Yemanov made changes - 25/Aug/14 01:32 PM
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.
Dmitry Yemanov added a comment - 25/Aug/14 01:33 PM - edited
Most probably, there will be no 2.1.x releases anymore, so it's out of question.

Dmitry Yemanov made changes - 25/Aug/14 01:41 PM
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 3.0 Beta 1 [ 10332 ]
Fix Version/s 2.5.4 [ 10585 ]
Resolution Fixed [ 1 ]
Pavel Zotov made changes - 29/May/15 04:48 PM
Status Resolved [ 5 ] Resolved [ 5 ]
QA Status Done successfully
Pavel Zotov made changes - 12/Jul/15 06:20 AM
Status Resolved [ 5 ] Resolved [ 5 ]
Test Details See also: CORE-4038, CORE-4492
Pavel Cisar made changes - 25/Sep/15 01:13 PM
Link This issue is related to QA-612 [ QA-612 ]