hummm... vc não disse qual a versão instalada...
A algumas versões atrás o IN tinha problemas de eficiencia. Mas como os
colegas já disseram, sem mais informações fica difícil...
PS: se este fou seu range no IN fixos, vc pode utilizar BETWEEN ...
Sds,
Marco Antonio
João Paulo wrote:
Olá pessoal,
Tenho a seguinte query que funciona perfeitamente, porém acho que ela
está demorando mais para executar. Passei pelo analyze e onde a query
demora mais é quando são feitos os dois in's quase no final da query,
alguem sabe me dizer se tenho como otimizar esta query para ela ficar
mas rápida.
select distinct
tabela1.campo1,t1.campo5,t1.campo6,tabela3.campo3,tabela6.campo2,count(*)
from tabela1,tabela2,tabela3,tabela4 t1,tabela4
t2,tabela5,tabela6,tabela7 t3,tabela7 t4
where tabela1.campo2=tabela2.campo2
and tabela1.campo3=tabela2.campo3
and tabela2.campo4='U'
and tabela1.datal between '2006-06-01' and '2006-06-30'
and tabela2.campo5=tabela3.campo3
and tabela3.campo4='A'
and tabela1.campo5=t1.campo6
and t1.campo7='A'
and t1.campo6=t2.campo5
and tabela1.campo8=tabela5.campo2
and tabela5.campo3=tabela6.campo2
and tabela1.campo1=t3.campo1
and t3.campo2=t4.campo3
and t3.campo2 in (1,2,3,4,5,6,7,8,9,10,11,12,13,14)
and t4.campo3 in (1000,1001,1002,1003,1004,1005)
group by tabela1.campo1,t1.campo5,t1.campo6,tabela3.campo3,tabela6.campo2;
João Paulo.
------------------------------------------------------------------------
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral