Demystifying Postgres Foreign Key Constraints on Citus
summary
Citus 11.3 enforces foreign keys by creating local FKs on nodes so each FK is checked by the Postgres instance that holds the relevant shard. Distributed FKs require colocation and same distribution key (one FK becomes N shard-to-shard FKs) and Citus disallows actions that would make shard keys null, so no CASCADE/SET NULL for distributed→reference. Local↔local and reference↔reference FKs work normally; local↔distributed and reference→distributed FKs are currently unsupported.
AI-written summary · about
chapters (4)
- 0:00Introduction
- 2:02What is a Foreign Key?
- 7:49Challenges of Foreign Keys on a distributed environment
- 9:06How Citus approaches foreign keys
related talks
28mEfficiently distributing Postgres with Citus – How to choose the right shard key?
08mFoundations of Distributed PostgreSQL with Citus
44mDistributed Postgres with Citus
31mSharding Without the Complexity
32m8 keys to the growth of Citus & Distributed PostgreSQL
28mHitchhiker's Guide to Row-Level Security in Citus
38mPostgreSQL as a distributed computing platform
27mWhat's new with constraints in Postgres 18
