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

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -