Presently in a single of my projects, we are supporting 32k organizations, however it's reaching its boundaries for performance, and therefore we are considering disbursing it to various databases according to their integer primary secrets. E.g. the very first 35k goes to 1 db, the following 35k to another db and so forth (according to (primary key % #db) logic).
However, this can present an issue when we are placing an entity into db. Since we do not know its primary key value in advance, how can we discover which db to place it into?
One possibility is maintaining a worldwide id table in just one db. Therefore we place in it first, obtain the primary key value after which utilize it to select a db for more detailed insertion. But this option would be not uniform and therefore hard to maintain and extend. So every other ideas on how to pull off it?