January 15th, 2013, 02:44 AM
Join Date: Jan 2013
Time spent in forums: 48 m 39 sec
Reputation Power: 0
What query is faster? JOIN, IN or EXISTS?
I have two tables:
A(id,a2) и B(a_id,b2)//A.id - PK, B.a_id - FK
N - amount of records in А , M - amount of records in B
What query is faster in FireBird 2.5
select B.b2 from B join A on A.id=B.a.id
select B.b2 from B where B.a_id in (select id from A)
select B.b2 from B where exists(select 1 from A where B.a_id=id)
Form math point of view
3-d faster. Time is M*(logN),
After that 2-d. Time is N+M*logN
And then 1-st. Time is M*N
But what about optimization of this operations in FireBird?
What operation is faster in real world?