Para tentar melhorar o desempenho, coloque os indices em tablespace direfente do tablespace da propria tabela e se tiver espaco de sobra adicione ... WITH (fillfactor = 10) Em 18/02/2014 23:08, "Prof. Cleverson" <prof_clever...@uniguacu.edu.br> escreveu:
> Em 18-02-2014 16:49, Prof. Cleverson escreveu: > >> Em 18-02-2014 16:38, Prof. Cleverson escreveu: >> >>> Tenho a seguinte consulta que retorna apenas 1 registro de 10 colunas: >>> select * from tac_avaliacao left join tac_nota on (codava=avanot) where >>> hisnot=359921 and fasava=81 >>> >>> a tabela avaliação tem 15000 registros >>> a tabela de notas tem 660000 registros >>> >>> explain: >>> "Nested Loop (cost=0.00..12474.40 rows=1 width=46) (actual >>> time=24228.265..45081.510 rows=1 loops=1)" >>> " Join Filter: (tac_avaliacao.codava = tac_nota.avanot)" >>> " Rows Removed by Join Filter: 1025" >>> " -> Index Scan using tac_avaliacao_fasava_idx on tac_avaliacao >>> (cost=0.00..4.55 rows=1 width=29) (actual time=0.020..1.927 rows=513 >>> loops=1)" >>> " Index Cond: (fasava = 81)" >>> " -> Seq Scan on tac_nota (cost=0.00..12469.80 rows=4 width=17) >>> (actual time=44.727..87.866 rows=2 loops=513)" >>> " Filter: (hisnot = 359921)" >>> " Rows Removed by Filter: 669822" >>> "Total runtime: 45081.543 ms" >>> >>> pq será que isto demora 45 segundos? Algum indice não está sendo usado? >>> >>> Um detalhe interessante que vi agora: se eu tirar a condição and >> fasava=81 a consulta demora 71 ms >> >> Resolvi. O indice abaixo caiu pra 17 ms > > CREATE INDEX tac_nota_hisnot_idx > ON tac_nota > USING btree > (hisnot); > > > > -- > .~. Prof. Cleverson B. Klettenberg > / v \ prof_clever...@uniguacu.edu.br > /( )\ > ^^-^^ Seja Livre! > > _______________________________________________ > pgbr-geral mailing list > pgbr-geral@listas.postgresql.org.br > https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral >
_______________________________________________ pgbr-geral mailing list pgbr-geral@listas.postgresql.org.br https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral