|Subject||RE: [firebird-support] Optimizer request|
(select partid from partners where partners.country = ‘Spain’) T
JOIN orders ON orders.partid = T.partid
Same result. No changes. Perfomance analyzer gives same result.
Never use IN (subselect). Change to
select * from orders where exists( select * from partners where partners.partid = orders.partid and partners.country = ‘Spain’)
I tried query with subquery in where clause and found big issue for this type of subquery.
select * from orders where orders.partid in (select partners.partid from partners where partners.country = ‘Spain’)
Perfomance Analysis returns me this
partners 687660 non index reads
orders 28657 index reads
If you analyze this result you’ll find that there is 687659 unnecessary non index reads. If developer of optimizer accept that all queries on the left side of where clouse has priority (and there is no way to be opposite) than we have big improvement in optimization.