Subject | RE: [firebird-support] Two complicated questions firebird 2.5 cs |
---|---|
Author | Svein Erling Tysvær |
Post date | 2011-09-21T11:44:30Z |
> and (Why bother to count at all? OK, it might not matter if the count is binary, but if it can be millions, then it can be time consuming. Rather, try
> (select count(*) from tfachres where artnr = :artnr) > 0
> and a.dispo = 0
> or coalesce((select count(*) from tfachres where artnr = :artnr), 0) <= 0
> and bestandsnr is null
> )
>
> Not sure if the query optimizer is smart enough to eval the count
> subquery only once.
and ((exists(select * from tfachres where artnr = :artnr)
and a.dispo = 0)
or (not exists(select * from tfachres where artnr = :artnr)
and a.bestandsnr is null))
HTH,
Set