entao,

Sera que o funcionamento do particionamento esta ligado a qnt de dados na
tabela? essas tabelas sao gigantes.

pq assim, quanto ao constraint_exclusion, esta on global e na sessao.

quanto ao cast, assim ja funciona em outros exemplos que uso na versao 8.3,
por exemplo.

pra nao passar por louco, criei no mesmo banco outra tabelas e o
particionamento funcionou:

O que mais pode estar errado?

CREATE TABLE teste
(
  te1 int,
  te2 timestamp
);

CREATE TABLE teste201109
(
like teste
)
INHERITS (teste) WITH ( OIDS=FALSE);
ALTER TABLE teste201109 ADD CHECK (te2 >= '2011-09-01'::date AND te2 <
'2011-10-01'::date);

CREATE TABLE teste201110
(
like teste
)
INHERITS (teste) WITH ( OIDS=FALSE);
ALTER TABLE teste201110 ADD CHECK (te2 >= '2011-10-01'::date AND te2 <
'2011-11-01'::date);
CREATE TABLE teste201111
(
like teste
)
INHERITS (teste) WITH ( OIDS=FALSE);
ALTER TABLE teste201111 ADD CHECK (te2 >= '2011-11-01'::date AND te2 <
'2011-12-01'::date);



Em 9 de dezembro de 2011 16:02, Flavio Henrique Araque Gurgel <
[email protected]> escreveu:

> > 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
>
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a