Postgres table 按表达式划分范围

Postgres table partition range by expression

我是 Postgres 中 table 分区的新手,我正在尝试一些似乎不起作用的东西。这是问题的简化版本:

cREATE table if not exists Location1 
PARTITION OF "Location"
FOR VALUES FROM
(extract(epoch from now()::timestamp))  
TO 
(extract(epoch from now()::timestamp)) ;

insert into "Location" ("BuyerId", "Location") 
values (416177285, point(-100, 100));

它失败了:

ERROR:  syntax error at or near "extract"
LINE 2:     FOR VALUES FROM (extract(epoch from now()::timestamp))

如果我尝试使用文字值创建分区,它工作正常。

我在 linux 上使用 Postgres 10。

经过大量的反复试验,我意识到 Postgres 10 并没有真正开箱即用的完整分区系统。对于可用的分区数据库,需要安装以下 postgres 模块:

pg_partman https://github.com/pgpartman/pg_partman(字面意思是上帝的礼物)

pg_jobmon https://github.com/omniti-labs/pg_jobmon(监视pg_partman正在做什么)

以上建议是给新手的,帮你避免很多头疼的问题。

我原以为由 postgres-core 自动创建分区是一件很简单的事情,但显然 postgres 开发人员知道一些我不知道的事情?

如果要求任何 80 年代的关系数据库插入一行,它会在通过约束检查后成功。

Postgres 2018最新版要求插入一行:"Sorry, I don't know where to put it."

这是一个很好的初步努力,但希望 Postgres 11 将有一个合适的分区系统 OOTB...