Subject | slow left join on a view. |
---|---|
Author | Samy Song |
Post date | 2002-11-19T17:20:06Z |
Did anyone had this problem, I'm trying to do a select with a left join on a
view with Firebird, also tested it on Interbase here is the case:
First select, contacts_view is a view with 3 tables left joined : city,
province and country.
select * from rooms r
left join contacts_view cv on cv.c_contact_code = r.owner ^
interbase : time 00:00:00:0071
PLAN JOIN (R NATURAL,JOIN (JOIN (JOIN (CV C NATURAL,CV CI INDEX
(CITY_CITY_ID)),CV P INDEX (PRO_PROVINCE)),CV CO INDEX (COUNTRY_COUNTRY)))
firebird : time 00:00:12:0488
PLAN JOIN (R NATURAL,JOIN (JOIN (JOIN (CV C NATURAL,CV CI INDEX
(CITY_CITY_ID)),CV P INDEX (PRO_PROVINCE)),CV CO INDEX (COUNTRY_COUNTRY)))
This one works great on both server:
select * from rooms r
left join contacts c on c.contact_code = r.owner
left join city ci on ci.city_id = c.city_id
left join provinces p on p.province = ci.province
left join country co on co.country = c.country ^
select * from rooms r
left join contacts_view cv on cv.c_contact_code = r.owner
order by r.room_number^
Interbase : .0080 SEC
PLAN SORT (JOIN (R NATURAL,JOIN (JOIN (JOIN (CV C NATURAL,CV CI INDEX
(CITY_CITY_ID)),CV P INDEX (PRO_PROVINCE)),CV CO INDEX (COUNTRY_COUNTRY))))
Firebird TIME : 12 SEC
PLAN SORT (JOIN (R NATURAL,JOIN (JOIN (JOIN (CV C NATURAL,CV CI INDEX
(CITY_CITY_ID)),CV P INDEX (PRO_PROVINCE)),CV CO INDEX (COUNTRY_COUNTRY))))
--Samy
view with Firebird, also tested it on Interbase here is the case:
First select, contacts_view is a view with 3 tables left joined : city,
province and country.
select * from rooms r
left join contacts_view cv on cv.c_contact_code = r.owner ^
interbase : time 00:00:00:0071
PLAN JOIN (R NATURAL,JOIN (JOIN (JOIN (CV C NATURAL,CV CI INDEX
(CITY_CITY_ID)),CV P INDEX (PRO_PROVINCE)),CV CO INDEX (COUNTRY_COUNTRY)))
firebird : time 00:00:12:0488
PLAN JOIN (R NATURAL,JOIN (JOIN (JOIN (CV C NATURAL,CV CI INDEX
(CITY_CITY_ID)),CV P INDEX (PRO_PROVINCE)),CV CO INDEX (COUNTRY_COUNTRY)))
This one works great on both server:
select * from rooms r
left join contacts c on c.contact_code = r.owner
left join city ci on ci.city_id = c.city_id
left join provinces p on p.province = ci.province
left join country co on co.country = c.country ^
select * from rooms r
left join contacts_view cv on cv.c_contact_code = r.owner
order by r.room_number^
Interbase : .0080 SEC
PLAN SORT (JOIN (R NATURAL,JOIN (JOIN (JOIN (CV C NATURAL,CV CI INDEX
(CITY_CITY_ID)),CV P INDEX (PRO_PROVINCE)),CV CO INDEX (COUNTRY_COUNTRY))))
Firebird TIME : 12 SEC
PLAN SORT (JOIN (R NATURAL,JOIN (JOIN (JOIN (CV C NATURAL,CV CI INDEX
(CITY_CITY_ID)),CV P INDEX (PRO_PROVINCE)),CV CO INDEX (COUNTRY_COUNTRY))))
--Samy