相关疑难解决方法(0)

基于检查约束的分区修剪未按预期工作

为什么下面的查询计划中包含表“events_201504”?根据我的查询和该表的检查约束,我希望查询规划器能够完全修剪它:

database=# \d events_201504
                                   Table "public.events_201504"
    Column     |            Type             |                           Modifiers
---------------+-----------------------------+---------------------------------------------------------------
 id            | bigint                      | not null default nextval('events_id_seq'::regclass)
 created_at    | timestamp without time zone |
Indexes:
    "events_201504_pkey" PRIMARY KEY, btree (id)
    "events_201504_created_at" btree (created_at)
Check constraints:
    "events_201504_created_at_check" CHECK (created_at >= '2015-04-01 00:00:00'::timestamp without time zone AND created_at <= '2015-04-30 23:59:59.999999'::timestamp without time zone)
Inherits: events
Run Code Online (Sandbox Code Playgroud)

时间及配置:

database=# select now();
              now
-------------------------------
 2015-05-25 16:49:20.037815-05

database=# show constraint_exclusion;
 constraint_exclusion
----------------------
 on
Run Code Online (Sandbox Code Playgroud)

查询计划:

database=# explain select count(1) from events where created_at …
Run Code Online (Sandbox Code Playgroud)

sql postgresql database-partitioning postgresql-performance postgresql-9.3

6
推荐指数
1
解决办法
3774
查看次数