CitusDB:不允许修改行的分区值
CitusDB: modifying the partition value of rows is not allowed
我想更新或删除测试数据库上的数据,使用基于 postgressql 的 citus,它会提示我以下信息:
不允许修改行的分区值
citus:6.0
postgresql:9.6
我如何在使用 citus 时更新或删除数据?
我认为在这种情况下错误消息有点令人困惑。不允许更新分布键值本身,但是,允许 update/delete 行证明分布键值。请参阅以下示例:
CREATE TABLE test_table (key int, value text);
-- distribute the table
SELECT create_distributed_table('test_table', 'key');
-- insert a row
INSERT INTO test_table VALUES (1, 'some test');
-- get the inserted row
SELECT * FROM test_table WHERE key = 1;
-- now, update the row
UPDATE test_table SET value = 'some another text' WHERE key = 1;
-- get the updated row
SELECT * FROM test_table WHERE key = 1;
-- now delete the row
DELETE FROM test_table WHERE key = 1;
-- see that the row is delete
SELECT * FROM test_table WHERE key = 1;
现在,让我举例说明什么是不允许的。不允许更新分布键值,因为该行已基于该值放置在分片上,更新该值可能会导致该行不再位于该分片中。
-- insert the row again
INSERT INTO test_table VALUES (1, 'some test');
-- now, try to update the distribution key value
UPDATE test_table SET key = 2 WHERE key = 1;
ERROR: modifying the partition value of rows is not allowed
希望对您有所帮助。
我想更新或删除测试数据库上的数据,使用基于 postgressql 的 citus,它会提示我以下信息: 不允许修改行的分区值 citus:6.0 postgresql:9.6 我如何在使用 citus 时更新或删除数据?
我认为在这种情况下错误消息有点令人困惑。不允许更新分布键值本身,但是,允许 update/delete 行证明分布键值。请参阅以下示例:
CREATE TABLE test_table (key int, value text);
-- distribute the table
SELECT create_distributed_table('test_table', 'key');
-- insert a row
INSERT INTO test_table VALUES (1, 'some test');
-- get the inserted row
SELECT * FROM test_table WHERE key = 1;
-- now, update the row
UPDATE test_table SET value = 'some another text' WHERE key = 1;
-- get the updated row
SELECT * FROM test_table WHERE key = 1;
-- now delete the row
DELETE FROM test_table WHERE key = 1;
-- see that the row is delete
SELECT * FROM test_table WHERE key = 1;
现在,让我举例说明什么是不允许的。不允许更新分布键值,因为该行已基于该值放置在分片上,更新该值可能会导致该行不再位于该分片中。
-- insert the row again
INSERT INTO test_table VALUES (1, 'some test');
-- now, try to update the distribution key value
UPDATE test_table SET key = 2 WHERE key = 1;
ERROR: modifying the partition value of rows is not allowed
希望对您有所帮助。