4 ms·
> No. Pick a a stable, guaranteed-to-exist, shard key (composite or atomic properties) and use that. If composite, order properties used in most-to-least distin
by preseinger 4y ago
> No. Pick a a stable, guaranteed-to-exist, shard key (composite or atomic properties) and use that. If composite, order properties used in most-to-least distinct value distribution.
what??
if you shard users by user ID and orders by order ID, then a query that joins a bunch of user orders in the same tenant namespace will spread across multiple user shards and multiple order shards
value distribution doesn't really have any impact here
(shard keys are also guaranteed to exist by definition, not clear what you mean by that)
if you don't care that specific queries cross sharding boundaries, okay, then no problem, but in that case sharding is not solving the problem that we are talking about here
> Sharding and multi-tenancy are orthogonal concepts.
sharding and multi-tenancy are only orthogonal if you don't care that a single tenant can have information on multiple shards
- AdieuToLogic 4y ago>> No. Pick a a stable, guaranteed-to-exist, shard key (composite or atomic properties) and use that. If composite, order properties used in most-to-least distinct value distribution. > what?? > if you shard users by user ID and orders by order ID, then a query that joins a bunch of user orders in the same tenant namespace will spread across multiple user shards and multiple order shards Note my recommendation of picking a "stable, guaranteed-to-exist, shard key." If there is a users table/collection sharded by its id and an orders table/collection sharded by its id, then there is no "guaranteed-to-exist shard key" between them, right? So, in that case, where the two are often accessed together, having a "guaranteed-to-exist shard key" of the "tenant namespace" would be the logical choice. > value distribution doesn't really have any impact here I mentioned value distribution strictly in the context of ordering composite shard keys (if applicable). My apologies for any confusion this might have introduced. > (shard keys are also guaranteed to exist by definition, not clear what you mean by that) My implication was in reference to what is always available across accessing sharded entities. In the scenario you describe, sharding by either user or order id would not be ideal. In situations where one or the other is not sharded, then identifying a common shard key likely is not needed. >> Sharding and multi-tenancy are orthogonal concepts. > sharding and multi-tenancy are only orthogonal if you don't care that a single tenant can have information on multiple shards My assertion was regarding theory, not specific scenarios. In practice, having multiple tables/collections needing shards with the tenant being the common entity strongly implies sharding on a tenant property and not of those unique to each table/collection, as implied in your reply.