Skip to content

Commit 5a1c947

Browse files
committed
Rework sharding tradeoffs table
1 parent c3d199a commit 5a1c947

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

articles/cosmos-db/postgresql/concepts-sharding-models.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,16 @@ Drawbacks:
5151

5252
## Sharding tradeoffs
5353

54-
<br />
55-
56-
|| Schema-based sharding | Row-based sharding|
57-
|---|---|---|
58-
|Multi-tenancy model|Separate schema per tenant|Shared tables with tenant ID columns|
59-
|Citus version|12.0+|All versions|
60-
|Extra steps compared to vanilla PostgreSQL|None, only a config change|Use create_distributed_table on each table to distribute & colocate tables by tenant ID|
61-
|Number of tenants|1-10k|1-1 M+|
62-
|Data modeling requirement|No foreign keys across distributed schemas|Need to include a tenant ID column (a distribution column, also known as a sharding key) in each table, and in primary keys, foreign keys|
63-
|SQL requirement for single node queries|Use a single distributed schema per query|Joins and WHERE clauses should include tenant_id column|
64-
|Parallel cross-tenant queries|No|Yes|
65-
|Custom table definitions per tenant|Yes|No|
66-
|Access control|Schema permissions|Schema permissions|
67-
|Data sharing across tenants|Yes, using reference tables (in a separate schema)|Yes, using reference tables|
68-
|Tenant to shard isolation|Every tenant has its own shard group by definition|Can give specific tenant IDs their own shard group via isolate_tenant_to_new_shard|
54+
| | Schema-based sharding | Row-based sharding |
55+
| --- | --- | --- |
56+
| **Multi-tenancy model** | Separate schema per tenant | Shared tables with tenant ID columns |
57+
| **Citus version** | 12.0+ | All versions |
58+
| **Extra steps compared to vanilla PostgreSQL** | None, only a config change | Use create_distributed_table on each table to distribute & colocate tables by tenant ID |
59+
| **Number of tenants** | 1-10k | 1-1 M+ |
60+
| **Data modeling requirement** | No foreign keys across distributed schemas | Need to include a tenant ID column (a distribution column, also known as a sharding key) in each table, and in primary keys, foreign keys |
61+
| **SQL requirement for single node queries** | Use a single distributed schema per query | Joins and WHERE clauses should include tenant_id column |
62+
| **Parallel cross-tenant queries** | No | Yes |
63+
| **Custom table definitions per tenant** | Yes | No |
64+
| **Access control** | Schema permissions | Schema permissions |
65+
| **Data sharing across tenants** | Yes, using reference tables (in a separate schema) | Yes, using reference tables |
66+
| **Tenant to shard isolation** | Every tenant has its own shard group by definition | Can give specific tenant IDs their own shard group via isolate_tenant_to_new_shard |

0 commit comments

Comments
 (0)