From: | Manuel Fernando Aller <manuel(dot)aller(at)gmail(dot)com> |
---|---|
To: | POSTGRESQL - Ayuda <pgsql-es-ayuda(at)postgresql(dot)org> |
Subject: | pregunta sobre particionado |
Date: | 2010-04-16 18:45:30 |
Message-ID: | 1271443530.12199.18.camel@manolo-notebd |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
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(dot)aller(at)gmail(dot)com>
From | Date | Subject | |
---|---|---|---|
Next Message | Jaime Casanova | 2010-04-16 19:04:41 | Re: pregunta sobre particionado |
Previous Message | Nahum Castro | 2010-04-16 17:53:15 | Re: error Instalando plr |