Já tentou: ... and t3.campo2 between 1 and 14 and t4.campo3 between 1000 and 1005 ... Mas o que não entendo é porque se t3.campo2=t4.campo3, t3.campo2 between 1 and 14 e t4.campo3 between 1000 and 1005 então não vai retornar nada, pois assim t3.campo2 nunca será igual a t4.campo3...
_____ De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Em nome de João Paulo Enviada em: segunda-feira, 28 de maio de 2007 11:32 Para: pgbr-geral@listas.postgresql.org.br Assunto: [pgbr-geral] otimização de query 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 pgbr-geral@listas.postgresql.org.br https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral