我有一个名为audittrailreference的大表,所以我根据日期对它进行了分区(一天1个表)。
该表有两个日期字段(intime& outtime)
对于任何一行,它们中的任何一行都可以为空,但不能同时为两者,或者它们都可能带有日期。
现在我需要使用约束排除来提高查询的性能。
我的表格结构如下:
CREATE TABLE myschema.auditrtailreference
(
event smallint,
innodeid character varying(80),
innodename character varying(80),
sourceid character varying(300),
intime timestamp without time zone,
outnodeid character varying(80),
outnodename character varying(80),
destinationid character varying(300),
outtime timestamp without time zone,
bytes integer,
cdrs integer,
noofsubfilesinfile integer,
recordsequencenumberlist character varying(1000),
partial_cdrs integer,
duplicate_cdrs integer,
discarded_cdrs integer,
created_cdrs integer,
corrupted_cdrs integer,
created_files integer,
duplicate_files integer,
corrupted_files integer,
partial_files integer,
discarded_files integer,
empty_files integer
)
WITH (
OIDS=FALSE
);
ALTER TABLE myschema.auditrtailreference
OWNER TO erix;
-- Trigger: auditrtailreference_trigger on myschema.auditrtailreference
-- DROP TRIGGER auditrtailreference_trigger ON myschema.auditrtailreference;
CREATE TRIGGER auditrtailreference_trigger
BEFORE INSERT
ON myschema.auditrtailreference
FOR EACH ROW
EXECUTE PROCEDURE myschema.auditrtailreference_partition_function();
答案 0 :(得分:0)
我是在我自己的兄弟那里完成的
感谢您的所有时间
CONSTRAINT "auditrtailreference_2014-10-02_intime_check" CHECK (intime >= '2014-10-02 00:00:00'::timestamp without time zone AND intime < '2014-10-03 00:00:00'::timestamp without time zone OR intime IS NULL),
CONSTRAINT "auditrtailreference_2014-10-02_outtime_check" CHECK (outtime >= '2014-10-02 00:00:00'::timestamp without time zone AND outtime < '2014-10-03 00:00:00'::timestamp without time zone OR outtime IS NULL)