Scott Marlowe wrote:
On 10/31/07, Pablo Alcaraz <pabloa(at)laotraesquina(dot)com(dot)ar> wrote:Steven Flatt wrote: On 10/30/07, Pablo Alcaraz <pabloa(at)laotraesquina(dot)com(dot)ar> wrote: Currently I have a insert rule only and the updates are right solved. I think the UPDATEs use the constraint because the program use the base table everywhere. This is the base table structure: -- Table: t -- DROP TABLE t; CREATE TABLE t ( idt bigint NOT NULL, idtpadre bigint NOT NULL, e integer NOT NULL, dmodi timestamp without time zone NOT NULL DEFAULT now(), p integer NOT NULL DEFAULT 0, m text NOT NULL ) WITHOUT OIDS; ALTER TABLE t OWNER TO e; -- Rule: "t_update_00003 ON t" -- DROP RULE t_update_00003 ON t; CREATE OR REPLACE RULE t_update_00003 AS ON INSERT TO t WHERE new.idt >= 1::bigint AND new.idt <= 30000000::bigint DO INSTEAD INSERT INTO t_00003 (idt, idtpadre, e, dmodi, p, m) VALUES (new.idt, new.idtpadre, new.e, new.dmodi, new.p, new.m); -- Rule: "t_update_00006 ON t" -- DROP RULE t_update_00006 ON t; CREATE OR REPLACE RULE t_update_00006 AS ON INSERT TO t WHERE new.idt >= 30000001::bigint AND new.idt <= 60000000::bigint DO INSTEAD INSERT INTO t_00006 (idt, idtpadre, e, dmodi, p, m) VALUES (new.idt, new.idtpadre, new.e, new.dmodi, new.p, new.m); -- Rule: "t_update_00009 ON t" -- DROP RULE t_update_00009 ON t; CREATE OR REPLACE RULE t_update_00009 AS ON INSERT TO t WHERE new.idt >= 60000001::bigint AND new.idt <= 90000000::bigint DO INSTEAD INSERT INTO t_00009 (idt, idtpadre, e, dmodi, p, m) VALUES (new.idt, new.idtpadre, new.e, new.dmodi, new.p, new.m); -- Rule: "t_update_00012 ON t" -- DROP RULE t_update_00012 ON t; CREATE OR REPLACE RULE t_update_00012 AS ON INSERT TO t WHERE new.idt >= 90000001::bigint AND new.idt <= 120000000::bigint DO INSTEAD INSERT INTO t_00012 (idt, idtpadre, e, dmodi, p, m) VALUES (new.idt, new.idtpadre, new.e, new.dmodi, new.p, new.m); etc ... 300 hundred partitions The partitions are created like: CREATE TABLE t_00003 ( CONSTRAINT t_00003_pkey PRIMARY KEY (idt), CONSTRAINT t_00003_idt_check CHECK (idt >= 1::bigint AND idt <= 30000000::bigint) ) INHERITS (t) WITHOUT OIDS; ALTER TABLE t_00003 OWNER TO e; CREATE INDEX t_00003_e ON t_00003 USING btree (e); etc |