Search code examples
postgresqlshardingcitus

Organize shards with citus data when tenant_id of a record is updated


I want to use citus data to shard my postgres database. before jumping into it i want to fully understand its behaviour in different scenarios. Although the docs explain most of the cases.

I want to know how would I go about moving data to a different shard when i update tenant_id of a record?


Solution

  • Citus errors out when you try to update the value of the partition column. You can move the data with INSERT INTO ... SELECT ... followed by a DELETE FROM ... inside a transaction.