This content has been marked as final. Show 4 replies
Hi,1 person found this helpful
That WHERE clause is needlessly complicated. Why not just say:
That won't solve the efficiency problem; Oracle isn't good with OR conditions.
... WHERE k.id_kontr = :b2 OR ( :b2 IS NULL AND k.cif_profile = :b1 )
Could you have 2 sepearate queries: one for when :b2 is NULL, and another for when :b2 is not NULL? The 2 queries would be identical except for the WHERE clause. Test :b2 first, and then run the appropriate query.
Thank You Frank, I really admire Your skills in finding logical equivalence :).
select * from (select * from tab1 where k.id_kontr = nvl(:b2,-1) or k.cif_profile = nvl2(:b2,-1,:b1) ) k, tab2 u and k.id = u.tk_id
Edited by: Etbin on 1.2.2013 20:34
Ooops! Should have looked before posting