Skip to content

Denormalise person properties #4272

@mariusandra

Description

@mariusandra

Is your feature request related to a problem?

We have a few problems with the persons table:

These problems all require some changes to the person tables and thus it makes sense to tackle them all together.

Describe the solution you'd like

I'd like to denormalise the person properties JSON field into a separate person_properties table. This means one property per user per row. This lets us update different properties independent of one another, and avoids sending multi-kilobyte JSON blobs to and from postgres. That in turn greatly improves data integrity, as we will get rid of the case where two plugin servers are updating (different!) properties on the user at the same time, and both read the same huge input json, modify one field. Then the second server, not knowing the first server already saved its changes, will override the first server's changes when writing its modified json back into postges.

This person properties table could start with collapsing merge tree on clickhouse, saving future refactoring.

Describe alternatives you've considered

In PostHog/plugin-server#326 @yakkomajuri went through some effort for $increment to update the field in the JSON via postgres. This avoids losing numbers when when two $increment calls update the same field at the same time, but the other server could still $set and override the entire properties json.

Additional context

:gottagofast:

Thank you for your feature request – we love each and every one!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions