Background
Weasel.SqlServer currently ships only RangePartitioning (ISqlServerPartitioning) with static, migration-time boundaries (additive ALTER PARTITION FUNCTION ... SPLIT RANGE). There is no managed/dynamic per-tenant partitioning API analogous to Weasel.Postgresql's ManagedListPartitions (Weasel.Postgresql/Tables/Partitioning/ManagedListPartitions.cs), which Marten relies on for per-tenant LIST partitions that grow as tenants are registered at runtime.
Why
Polecat (the SQL Server event store / "Marten for SQL Server") is implementing per-tenant event partitioning — JasperFx/polecat#163. The bounded-scan win comes from per-tenant sequences, but the issue also calls for physical per-tenant partitioning of pc_events / pc_streams. Without a managed-partition API in Weasel.SqlServer, Polecat would have to hand-roll runtime CREATE PARTITION FUNCTION / ALTER PARTITION FUNCTION ... SPLIT RANGE DDL as tenants join, which violates the "use Weasel for all schema management" principle and duplicates logic Weasel already owns for PostgreSQL.
Proposal
Add a managed per-tenant partitioning strategy to Weasel.SqlServer mirroring ManagedListPartitions:
- A
ManagedRangePartitions (or ManagedTenantPartitions) ISqlServerPartitioning implementation that:
- tracks the desired set of tenant boundary values (e.g. a tenant-ordinal column),
- emits
CREATE PARTITION FUNCTION + CREATE PARTITION SCHEME for the initial set,
- computes an additive delta and emits
SPLIT RANGE for newly-added tenants at migration time,
- exposes a runtime "add tenant/boundary" operation (idempotent
SPLIT RANGE) so a store can register a new tenant partition without a full migration.
- Consider a small registry-table convention (tenant_id → ordinal) so the partition column is a compact
int rather than a varchar tenant id.
Acceptance
Related
Background
Weasel.SqlServercurrently ships onlyRangePartitioning(ISqlServerPartitioning) with static, migration-time boundaries (additiveALTER PARTITION FUNCTION ... SPLIT RANGE). There is no managed/dynamic per-tenant partitioning API analogous toWeasel.Postgresql'sManagedListPartitions(Weasel.Postgresql/Tables/Partitioning/ManagedListPartitions.cs), which Marten relies on for per-tenant LIST partitions that grow as tenants are registered at runtime.Why
Polecat (the SQL Server event store / "Marten for SQL Server") is implementing per-tenant event partitioning — JasperFx/polecat#163. The bounded-scan win comes from per-tenant sequences, but the issue also calls for physical per-tenant partitioning of
pc_events/pc_streams. Without a managed-partition API in Weasel.SqlServer, Polecat would have to hand-roll runtimeCREATE PARTITION FUNCTION/ALTER PARTITION FUNCTION ... SPLIT RANGEDDL as tenants join, which violates the "use Weasel for all schema management" principle and duplicates logic Weasel already owns for PostgreSQL.Proposal
Add a managed per-tenant partitioning strategy to
Weasel.SqlServermirroringManagedListPartitions:ManagedRangePartitions(orManagedTenantPartitions)ISqlServerPartitioningimplementation that:CREATE PARTITION FUNCTION+CREATE PARTITION SCHEMEfor the initial set,SPLIT RANGEfor newly-added tenants at migration time,SPLIT RANGE) so a store can register a new tenant partition without a full migration.intrather than avarchartenant id.Acceptance
Weasel.SqlServerexposes a managed per-tenant partitioning strategy with additive migration + runtime add-boundaryRelated
Weasel.Postgresql/Tables/Partitioning/ManagedListPartitions.cs— the PostgreSQL reference