sql - How to improve select with not in on firebird -
select mid aplicacao mid not in ( select distinct mid aplicacao inner join prod_app on prod_app.mid=aplicacao.mid prod_app.coditem=1 )
i try search solution on firebird improve query unfortunatelly didn´t have success. please me?
the common solution in
(and not in
) performance problems use exists
(or not exists
) instead:
select mid aplicacao not exists ( select 1 prod_app prod_app.mid = aplicacao.mid , prod_app.coditem=1 )
another solution use left join
, filter on non-existence of right side:
select mid aplicacao left join prod_app on prod_app.mid = aplicacao.mid , prod_app.coditem=1 prod.app.coditem null
note additional filter conditions on prod_app
(like prod_app.coditem=1
) need part of join condition, not of where
clause.
Comments
Post a Comment