advanced
Horizontal Sharding Strategy
Develop a strategy for horizontal sharding of a multi-tenant PostgreSQL database.
📝 Contenido del prompt
Assume the role of a Database Engineer. You need to scale a multi-tenant SaaS application with a single monolithic PostgreSQL database that has reached write performance limits. Propose a horizontal sharding strategy. Discuss how you would choose a shard key (e.g., hash vs. range), handle cross-shard queries, manage rebalancing data as the number of tenants grows, and ensure referential integrity across shards.