Skip to content

Epic: Segment Membership Inspection — V1 (Beta) #7469

@khvn26

Description

@khvn26

Roll out the columnar-backed segment membership feature to SaaS. Supersedes #7405 (bitmap design).

Feature flags

  • segment_membership_inspection (Flagsmith on Flagsmith) — gates the SaaS rollout per organisation, plus the denylist for spend outliers.

Core concept

flagsmith-sql-flag-engine translates a segment's predicate tree to a SQL WHERE expression. Identities are mirrored from DynamoDB to ClickHouse — daily backfill during Alpha, retired during V1 in favour of Edge CDC (Dynamo Streams → S3 → ClickPipes → ClickHouse). Per-(segment, environment) counts cache in core Postgres on the SegmentMembership model. Members listing streams matched identities from ClickHouse, enriched with the canonical Dynamo record.

The IDENTITIES table is ReplacingMergeTree(inserted_at) ORDER BY (environment_id, id) with traits in a JSON column. Refresh queries use FROM IDENTITIES AS i FINAL to dedupe at read time so counts always reflect the latest backfill snapshot.

History: the Alpha PoC originally landed on Snowflake. After the 12/05/2026 RFC review the cost analysis tipped us toward ClickHouse for V1; the engine dialect (Flagsmith/flagsmith-sql-flag-engine#8) and the PoC backend (Flagsmith/flagsmith#7464) have since migrated.

RFC: Segment Membership Inspection (columnar) (private to Flagsmith team).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions