Boa tarde,

Estou montado esse select e esta muito lento, alguem pode me ajudar?

"GroupAggregate  (cost=129002.43..129002.63 rows=4 width=412)"
"  ->  Sort  (cost=129002.43..129002.44 rows=4 width=412)"
" Sort Key: ('Saídas '::character(15)), its.codigo_empresa, ite.codigo_anterior"
"        ->  Result  (cost=64501.16..129002.39 rows=4 width=412)"
"              ->  Append  (cost=64501.16..129002.39 rows=4 width=412)"
" -> HashAggregate (cost=64501.16..64501.18 rows=2 width=24)" " -> Nested Loop (cost=0.00..64494.91 rows=49 width=24)" " -> Nested Loop (cost=0.00..16.55 rows=1 width=13)" " -> Index Scan using pk_item_codigo on item ite (cost=0.00..8.27 rows=1 width=13)"
"                                            Index Cond: (codigo = 724)"
" -> Index Scan using pk_unidade_codigo on unidade un (cost=0.00..8.27 rows=1 width=8)" " Index Cond: (codigo = ite.codigo_unidade)" " -> Append (cost=0.00..64477.86 rows=49 width=19)" " -> Index Scan using pk_item_mensal_empite on item_mensal its (cost=0.00..44868.51 rows=17 width=19)" " Index Cond: (codigo_item = 724)" " Filter: ((ano_ref >= '2015-10-01'::date) AND (ano_ref <= '2016-09-30'::date))" " -> Bitmap Heap Scan on item_mensal_2015 its (cost=2403.94..9512.31 rows=19 width=19)" " Recheck Cond: ((ano_ref >= '2015-10-01'::date) AND (ano_ref <= '2016-09-30'::date))"
"                                            Filter: (codigo_item = 724)"
" -> Bitmap Index Scan on idx_item_mensal_da2015 (cost=0.00..2403.94 rows=114364 width=0)" " Index Cond: ((ano_ref >= '2015-10-01'::date) AND (ano_ref <= '2016-09-30'::date))" " -> Seq Scan on item_mensal_2016 its (cost=0.00..10097.04 rows=13 width=18)" " Filter: ((ano_ref >= '2015-10-01'::date) AND (ano_ref <= '2016-09-30'::date) AND (codigo_item = 724))" " -> HashAggregate (cost=64501.16..64501.18 rows=2 width=23)" " -> Nested Loop (cost=0.00..64494.91 rows=49 width=23)" " -> Nested Loop (cost=0.00..16.55 rows=1 width=13)" " -> Index Scan using pk_item_codigo on item ite (cost=0.00..8.27 rows=1 width=13)"
"                                            Index Cond: (codigo = 724)"
" -> Index Scan using pk_unidade_codigo on unidade un (cost=0.00..8.27 rows=1 width=8)" " Index Cond: (codigo = ite.codigo_unidade)" " -> Append (cost=0.00..64477.86 rows=49 width=18)" " -> Index Scan using pk_item_mensal_empite on item_mensal its (cost=0.00..44868.51 rows=17 width=18)" " Index Cond: (codigo_item = 724)" " Filter: ((ano_ref >= '2015-10-01'::date) AND (ano_ref <= '2016-09-30'::date))" " -> Bitmap Heap Scan on item_mensal_2015 its (cost=2403.94..9512.31 rows=19 width=18)" " Recheck Cond: ((ano_ref >= '2015-10-01'::date) AND (ano_ref <= '2016-09-30'::date))"
"                                            Filter: (codigo_item = 724)"
" -> Bitmap Index Scan on idx_item_mensal_da2015 (cost=0.00..2403.94 rows=114364 width=0)" " Index Cond: ((ano_ref >= '2015-10-01'::date) AND (ano_ref <= '2016-09-30'::date))" " -> Seq Scan on item_mensal_2016 its (cost=0.00..10097.04 rows=13 width=18)" " Filter: ((ano_ref >= '2015-10-01'::date) AND (ano_ref <= '2016-09-30'::date) AND (codigo_item = 724))"

<<attachment: cgcesarsoares.vcf>>

_______________________________________________
pgbr-geral mailing list
pgbr-geral@listas.postgresql.org.br
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a