> o problema é que só deveria percorrer a tabela 201109 e 201110, porem o
> explain mostra que esta percorrendo todas as tabelas.
>
>
>
>  Aggregate  (cost=585580.51..585580.52 rows=1 width=0)"
> "  ->  Append  (cost=4.91..570750.60 rows=5931962 width=0)"
> "        ->  Bitmap Heap Scan on ocorrencia_evento  (cost=4.91..15.87
> rows=64 width=0)"
> "              Recheck Cond: ((ocoedt_pacote >= '2011-09-21
> 00:00:00-03'::timestamp with time zone) AND (ocoedt_pacote <= '2011-10-20
> 23:59:00-02'::timestamp with time zone))"
> "              ->  Bitmap Index Scan on ocorrencia_evento_ocoedt_pacote_idx
> (cost=0.00..4.89 rows=64 width=0)"
> "                    Index Cond: ((ocoedt_pacote >= '2011-09-21
> 00:00:00-03'::timestamp with time zone) AND (ocoedt_pacote <= '2011-10-20
> 23:59:00-02'::timestamp with time zone))"
> "        ->  Index Scan using ocorrencia_evento201112_idx on
> ocorrencia_evento201112 ocorrencia_evento  (cost=0.00..8.85 rows=1 width=0)"
> "              Index Cond: ((ocoedt_pacote >= '2011-09-21
> 00:00:00-03'::timestamp with time zone) AND (ocoedt_pacote <= '2011-10-20
> 23:59:00-02'::timestamp with time zone))"
> "        ->  Index Scan using ocorrencia_evento201111_idx on
> ocorrencia_evento201111 ocorrencia_evento  (cost=0.00..9.55 rows=1 width=0)"
> "              Index Cond: ((ocoedt_pacote >= '2011-09-21
> 00:00:00-03'::timestamp with time zone) AND (ocoedt_pacote <= '2011-10-20
> 23:59:00-02'::timestamp with time zone))"
> "        ->  Index Scan using ocorrencia_evento201106_idx on
> ocorrencia_evento201106 ocorrencia_evento  (cost=0.00..8.66 rows=1 width=0)"
> "              Index Cond: ((ocoedt_pacote >= '2011-09-21
> 00:00:00-03'::timestamp with time zone) AND (ocoedt_pacote <= '2011-10-20
> 23:59:00-02'::timestamp with time zone))"
> "        ->  Index Scan using ocorrencia_evento201107_idx on
> ocorrencia_evento201107 ocorrencia_evento  (cost=0.00..8.97 rows=1 width=0)"
> "              Index Cond: ((ocoedt_pacote >= '2011-09-21
> 00:00:00-03'::timestamp with time zone) AND (ocoedt_pacote <= '2011-10-20
> 23:59:00-02'::timestamp with time zone))"
> "        ->  Index Scan using ocorrencia_evento201108_idx on
> ocorrencia_evento201108 ocorrencia_evento  (cost=0.00..9.13 rows=1 width=0)"
> "              Index Cond: ((ocoedt_pacote >= '2011-09-21
> 00:00:00-03'::timestamp with time zone) AND (ocoedt_pacote <= '2011-10-20
> 23:59:00-02'::timestamp with time zone))"
> "        ->  Bitmap Heap Scan on ocorrencia_evento201109 ocorrencia_evento
> (cost=58118.01..253244.81 rows=2265453 width=0)"
> "              Recheck Cond: ((ocoedt_pacote >= '2011-09-21
> 00:00:00-03'::timestamp with time zone) AND (ocoedt_pacote <= '2011-10-20
> 23:59:00-02'::timestamp with time zone))"
> "              ->  Bitmap Index Scan on ocorrencia_evento201109_idx
> (cost=0.00..57551.65 rows=2265453 width=0)"
> "                    Index Cond: ((ocoedt_pacote >= '2011-09-21
> 00:00:00-03'::timestamp with time zone) AND (ocoedt_pacote <= '2011-10-20
> 23:59:00-02'::timestamp with time zone))"
> "        ->  Bitmap Heap Scan on ocorrencia_evento201110 ocorrencia_evento
> (cost=94062.17..317444.77 rows=3666440 width=0)"
> "              Recheck Cond: ((ocoedt_pacote >= '2011-09-21
> 00:00:00-03'::timestamp with time zone) AND (ocoedt_pacote <= '2011-10-20
> 23:59:00-02'::timestamp with time zone))"
> "              ->  Bitmap Index Scan on ocorrencia_evento201110_idx
> (cost=0.00..93145.56 rows=3666440 width=0)"
> "                    Index Cond: ((ocoedt_pacote >= '2011-09-21
> 00:00:00-03'::timestamp with time zone) AND (ocoedt_pacote <= '2011-10-20
> 23:59:00-02'::timestamp with time zone))"

Tente fazer a restrição sem cast (elimine o ::date por exemplo).
Verifique na sua sessão:
SHOW constraint_exclusion;
se está correto mesmo. Pode ter sido alterado para o seu usuário.
Em tempo, basta o modo 'partition' na versão 8.4 ou mais recentes, não
precisa ser 'on'.

[]s
Flavio Gurgel
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a