Postgresql 过时的行不';t从外部表分区postgres移出

Postgresql 过时的行不';t从外部表分区postgres移出,postgresql,sharding,Postgresql,Sharding,我正在努力学习如何在Postgres中配置分片 我的Postgres设置有一个温度表,该表有4个分区,每个分区覆盖不同的“时间戳”值范围 温度\u 201904表尤其是外来表 postgres=# \d+ temperature_201904 Foreign table "public.temperature_201904" Column | Ty

我正在努力学习如何在Postgres中配置分片

我的Postgres设置有一个
温度
表,该表有4个分区,每个分区覆盖不同的“时间戳”值范围

温度\u 201904
表尤其是外来表

postgres=# \d+ temperature_201904 
                                                           Foreign table "public.temperature_201904"
  Column   |            Type             | Collation | Nullable |                 Default                 | FDW options | Storage | Stats target | Description 
-----------+-----------------------------+-----------+----------+-----------------------------------------+-------------+---------+--------------+-------------
 id        | bigint                      |           | not null | nextval('temperature_id_seq'::regclass) |             | plain   |              | 
 city_id   | integer                     |           | not null |                                         |             | plain   |              | 
 timestamp | timestamp without time zone |           | not null |                                         |             | plain   |              | 
 temp      | numeric(5,2)                |           | not null |                                         |             | main    |              | 
Partition of: temperature FOR VALUES FROM ('2019-04-01 00:00:00') TO ('2019-05-01 00:00:00')
Partition constraint: (("timestamp" IS NOT NULL) AND ("timestamp" >= '2019-04-01 00:00:00'::timestamp without time zone) AND ("timestamp" < '2019-05-01 00:00:00'::timestamp without time zone))
Server: shard02
但是,如果我更新此行的时间戳,使其在为分区定义的范围内不再有效,我希望它被移出并放置到正确的分区中,
temperature\u 201901
,但它不是

postgres=# update temperature set timestamp =  '2019-01-04' where id=1;
UPDATE 1
postgres=# select * from temperature_201904 ;
 id | city_id |      timestamp      | temp  
----+---------+---------------------+-------
  1 |       1 | 2019-01-04 00:00:00 | 12.30
再次重申,该表的温度范围为('2019-04-01 00:00:00')到('2019-05-01 00:00:00')
,是一个外来表

感觉好像我错过了什么

这是预期的行为吗?如果是这样的话,是否有一种方法可以配置为当节点的分区约束发生变化时,数据会自动在节点之间移动

提前谢谢

postgres=# SELECT version();
                                                     version                                                      
------------------------------------------------------------------------------------------------------------------
 PostgreSQL 12.2 (Debian 12.2-2.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit

这似乎是意料之中的事。从

虽然行可以从本地分区移动到外部表分区(前提是外部数据包装器支持元组路由),但它们不能从外部表分区移动到另一个分区


现在,我希望出现一个错误,而不是默默地违反隐含的约束,但我不希望它按照您希望的方式工作。

这似乎是意料之中的。从

虽然行可以从本地分区移动到外部表分区(前提是外部数据包装器支持元组路由),但它们不能从外部表分区移动到另一个分区


现在,我希望出现一个错误,而不是默默地违反隐含的约束,但我不希望它按照您希望的方式工作。

我不知道这是预期的还是一个错误,最好询问pgsql黑客邮件列表。但是,如果您在实际工作负载中更新分区键,您的设计就不好。@LaurenzAlbe“但是如果您在实际工作负载中更新分区键,您的设计就不好”我认为分区的一个重要用例是单独物理移动行(因为键一次更新一行)这样,将来的批量操作,如批量删除或归档,创伤更小。@jjames如果你这么说的话。。。我认为分区的要点是,您不必进行批量删除或更新,而是删除或重新附加分区。我不知道这是预期的还是错误,最好询问pgsql黑客邮件列表。但是,如果您在实际工作负载中更新分区键,您的设计就不好。@LaurenzAlbe“但是如果您在实际工作负载中更新分区键,您的设计就不好”我认为分区的一个重要用例是单独物理移动行(因为键一次更新一行)这样,将来的批量操作,如批量删除或归档,创伤更小。@jjames如果你这么说的话。。。我认为分区的要点是,您不必进行批量删除或更新,而是删除或重新附加分区。
postgres=# update temperature set timestamp =  '2019-01-04' where id=1;
UPDATE 1
postgres=# select * from temperature_201904 ;
 id | city_id |      timestamp      | temp  
----+---------+---------------------+-------
  1 |       1 | 2019-01-04 00:00:00 | 12.30
postgres=# SELECT version();
                                                     version                                                      
------------------------------------------------------------------------------------------------------------------
 PostgreSQL 12.2 (Debian 12.2-2.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit