Hola a todos, estoy intentando aplicar particionado de tablas, les
comento mi esquema:

tabla maestra, las tablas 'hijas' creadas como:
CREATE TABLE maestra201004 (
    CHECK ( maestra_timestamp >= timestamp '2010-04-01 00:00:00' AND
            maestra_timestamp < timestamp '2010-05-01 00:00:00' )
) INHERITS (maestra);

índice en el campo maestra_timestamp (en la maestra y en las hijas);
un trigger:
CREATE TRIGGER insert_maestra_trigger
  BEFORE INSERT
  ON maestra
  FOR EACH ROW
  EXECUTE PROCEDURE maestra_insert_trigger();
y un procedimiento:
CREATE OR REPLACE FUNCTION maestra_insert_trigger()
  RETURNS trigger AS
$BODY$
BEGIN
  IF ( NEW.maestra_timestamp < timestamp '2008-10-01 00:00:00' AND
    NEW.maestra_timestamp >= timestamp '2008-09-01 00:00:00') THEN
      INSERT INTO maestra200809 VALUES (NEW.*);
    ELSIF ( NEW.maestra_timestamp < timestamp '2008-11-01 00:00:00' AND
      NEW.maestra_timestamp >= timestamp '2008-10-01 00:00:00' ) THEN
      INSERT INTO maestra200810 VALUES (NEW.*);
..........
    ELSE
      INSERT INTO billing_ws_cti201004 VALUES (NEW.*);
    END IF;
    RETURN NULL;
END;
$BODY$
  LANGUAGE 'plpgsql';

Ahora bien, llegado el momento de probar la performance, tengo la tabla
maestra en 2 bases distintas (en la misma máquina), una partida como se
describió, y una toda en una tabla.

el select:
select * from maestra where maestra_timestamp > '2010-02-01 00:00:00'
order by maestra_timestamp desc limit 3;

tarda casi 12 segundos en el esquema particionado, y 0,3 segundos en el
otro esquema:
partida: real   0m11.642s
original:real   0m0.013s
no importa si seteo constraint_exclusion (SET constraint_exclusion=on;)
el select sobre la particionada tarda siempre 11 segundos y medio.

Qué olvidé considerar?

Gracias,

-- 
Manuel Fernando Aller <manuel.al...@gmail.com>

--
TIP 3: Si encontraste la respuesta a tu problema, publ�cala, otros te lo 
agradecer�n

Responder a