Try:

select orders.*
from
  (select partid from partners where partners.country = ‘Spain’) T
  JOIN orders ON orders.partid = T.partid

From: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com]
Sent: September 9, 2016 12:06 PM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] Optimizer request




Same result. No changes. Perfomance analyzer gives same result.

Djordje

From: mailto:firebird-support@yahoogroups.com
Sent: Friday, September 09, 2016 5:10 PM
To: firebird-support@yahoogroups.com<mailto:firebird-support@yahoogroups.com>
Subject: Re: [firebird-support] Optimizer request


Never use IN (subselect). Change to

select * from orders where exists( select * from partners where partners.partid 
= orders.partid and partners.country = ‘Spain’)

2016-09-09 14:30 GMT+02:00 'Djordje Radovanovic' 
softsis...@sbb.rs<mailto:softsis...@sbb.rs> [firebird-support] 
<firebird-support@yahoogroups.com<mailto:firebird-support@yahoogroups.com>>:

I tried query with subquery in where clause and found big issue for this type 
of subquery.

for example:

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.

Best regards,

Djordje Radovanovic








  • [firebird-supp... 'Djordje Radovanovic' softsis...@sbb.rs [firebird-support]
    • Re: [fire... Dimitry Sibiryakov s...@ibphoenix.com [firebird-support]
    • Re: [fire... Svein Erling Tysvær setys...@gmail.com [firebird-support]
      • Re: [... 'Djordje Radovanovic' softsis...@sbb.rs [firebird-support]
        • R... 'Leyne, Sean' s...@broadviewsoftware.com [firebird-support]
          • ... 'Djordje Radovanovic' softsis...@sbb.rs [firebird-support]
            • ... 'Leyne, Sean' s...@broadviewsoftware.com [firebird-support]
      • Re: [... ehmmm.fireb...@seznam.cz [firebird-support]
        • [... Virgo Pärna virgo.pa...@mail.ee [firebird-support]
    • Re: [fire... 'Arno Brinkman' fbsupp...@abvisie.nl [firebird-support]
      • Re: [... Louis Kleiman lklei...@sstms.com [firebird-support]
    • Re: [fire... Ann Harrison aharri...@ibphoenix.com [firebird-support]
      • Re: [... Helen Borrie hele...@iinet.net.au [firebird-support]
        • R... Ann Harrison aharri...@ibphoenix.com [firebird-support]
      • Re: [... 'Djordje Radovanovic' softsis...@sbb.rs [firebird-support]

Reply via email to