简体   繁体   English

Postgresql 约束排除

[英]Postgresql constraint exclusion

I have a huge table named audittrailreference so I partitioned it on the basis of date (1 table for a day).我有一个名为 audittrailreference 的大表,所以我根据日期对其进行了分区(一天 1 个表)。

The table has two date fields (intime & outtime)该表有两个日期字段(intime 和 outtime)

for any row either of them could be null but not both or it might be possible that both of them may carry date.对于任何行,它们中的任何一个都可以为空,但不能同时为空,或者它们都可能带有日期。

Now I need to put the constraint exclusion to increase the performance of my queries.现在我需要放置约束排除以提高查询的性能。

my table structure is as follows:我的表结构如下:

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();

I have done it on my own brothers我已经在我自己的兄弟身上做到了

Thanks to all for your time感谢大家的时间

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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM