Senior
How was PostgreSQL sharding implemented — what served as the router?
sobes.tech AI
Answer from AI
In PostgreSQL sharding implementation, an external router or proxy is often used to direct requests to the appropriate sharded database instance. The router can be:
- A specialized proxy server (e.g., Pgpool-II, Citus coordinator) that analyzes requests and redirects them.
- The application's own logic, which selects the required database instance based on the sharding key.
In some cases, middleware or a service that accepts requests and distributes them across shards, providing transparency for the client, is used.
Thus, a "router" is a component that knows how to map a sharding key to a specific PostgreSQL server and direct the request there.