Subject | Can someone explain this PLAN ! |
---|---|
Author | radovan.antloga@siol.net |
Post date | 2001-11-02T22:04:35Z |
Hi all !
For test purpose I have used employee.gdb database but I
have the same situations in my production database.
Employee table has index defined on last_name,first_name.
If you write:
Test 1:
-------------------------------------------------------------------
select *
from employee
order by last_name,first_name
you will get: PLAN (EMPLOYEE ORDER NAMEX)
-------------------------------------------------------------------
but when you do left join like this:
Test 2:
------------------------------------------------------------------
select e.*,p.*
from employee e
left join employee_project p on(e.emp_no=p.emp_no)
order by e.last_name, e.first_name
you will get: PLAN SORT (JOIN E NATURAL, P INDEX (RDB$PRIMARY14)))
------------------------------------------------------------------
but when you do this:
Test 3:
------------------------------------------------------------------
select e.*,p.*
from employee e, employee_project p
where e.emp_no=p.emp_no
order by e.last_name,e.first_name
you will get: PLAN JOIN (E ORDER NAMEX, P INDEX (RDB$PRIMARY14))
I would expect that Test 2 would use the same PLAN as Test 3.
If you have large tables (1 milion records) you must be careful
if you use left join. I tried to force my PLAN but without success.
I tried this tests with IB 6 (latest build), FB 1.0.0. Beta2, FB 0.9.4
Best Regards
Rado Antloga
For test purpose I have used employee.gdb database but I
have the same situations in my production database.
Employee table has index defined on last_name,first_name.
If you write:
Test 1:
-------------------------------------------------------------------
select *
from employee
order by last_name,first_name
you will get: PLAN (EMPLOYEE ORDER NAMEX)
-------------------------------------------------------------------
but when you do left join like this:
Test 2:
------------------------------------------------------------------
select e.*,p.*
from employee e
left join employee_project p on(e.emp_no=p.emp_no)
order by e.last_name, e.first_name
you will get: PLAN SORT (JOIN E NATURAL, P INDEX (RDB$PRIMARY14)))
------------------------------------------------------------------
but when you do this:
Test 3:
------------------------------------------------------------------
select e.*,p.*
from employee e, employee_project p
where e.emp_no=p.emp_no
order by e.last_name,e.first_name
you will get: PLAN JOIN (E ORDER NAMEX, P INDEX (RDB$PRIMARY14))
I would expect that Test 2 would use the same PLAN as Test 3.
If you have large tables (1 milion records) you must be careful
if you use left join. I tried to force my PLAN but without success.
I tried this tests with IB 6 (latest build), FB 1.0.0. Beta2, FB 0.9.4
Best Regards
Rado Antloga