Ship the ability to count, list, sample, and stream the identities matching a segment, in both self-hosted and Edge API projects.
Settings
settings.SEGMENT_MEMBERSHIP_ENABLED — Django boolean. Off by default, gates index maintenance signals so the feature is a dark no-op in self-hosted and SaaS until enabled.
Feature flags
segment_membership_index (Flagsmith on Flagsmith) — gates the SaaS rollout per organisation, plus the denylist for outlier orgs.
Core concept
Reduce segment evaluation to set algebra over a finite atom basis, materialise atoms as Roaring bitmaps in core Postgres, compose bitmaps to compute membership. Async maintenance via task processor. Read API exposes count / sample / members. Edge envs populated via DDB scan during backfill (no CDC in v1).
PK-as-ordinal: Identity.id is the bitmap ord directly — no IdentityOrdinal table, no allocation hot path.
User-facing documentation PR: #7399.
Notes
The RFC is the source of truth for design decisions: https://www.notion.so/355a2b634bf9815289b3d070e164f9eb (private to the Flagsmith team). Notable choices baked into v1:
Tech debt knowingly taken on:
Ship the ability to count, list, sample, and stream the identities matching a segment, in both self-hosted and Edge API projects.
Settings
settings.SEGMENT_MEMBERSHIP_ENABLED— Django boolean. Off by default, gates index maintenance signals so the feature is a dark no-op in self-hosted and SaaS until enabled.Feature flags
segment_membership_index(Flagsmith on Flagsmith) — gates the SaaS rollout per organisation, plus the denylist for outlier orgs.Core concept
Reduce segment evaluation to set algebra over a finite atom basis, materialise atoms as Roaring bitmaps in core Postgres, compose bitmaps to compute membership. Async maintenance via task processor. Read API exposes count / sample / members. Edge envs populated via DDB scan during backfill (no CDC in v1).
PK-as-ordinal:
Identity.idis the bitmap ord directly — noIdentityOrdinaltable, no allocation hot path.User-facing documentation PR: #7399.
Notes
The RFC is the source of truth for design decisions: https://www.notion.so/355a2b634bf9815289b3d070e164f9eb (private to the Flagsmith team). Notable choices baked into v1:
IdentityOrdinaltable). Saves ~270 GB of ordinal mapping at SaaS scale.as_ofand manual refresh. CDC tracked in Flagsmith/edge-api#612.Tech debt knowingly taken on: