Postgres: Horizontalal Sharding
How should I shard my databases?
This is entirely dependent on the access patterns of your application. A good rule, though, is to look at your indexes. If every query goes through an index on
:user_id
, then chances are that you should shard on:user_id
. If half of your queries go through:user_id
and the other half go through:job_id
, then you may need to create two sets of shards, each with its own model, and have your application write to both.