Question

Postgres: should I use a JSONB column for user settings?

Solved · 7 views · asked by ines_data · edited

Twenty settings, some booleans, some strings. Cursor suggests one settings jsonb column.

What I’ve tried

Considered twenty columns. Feels wrong too.

Comment

1 answer

Marked as helpful by the asker
olu_backend · edited

JSONB is right for settings: they change often, they are read as a unit, and you rarely query by them. Two rules: validate the shape in the app (a Zod schema), and the moment you need where settings->>'x' = ... in a hot query, promote that key to a real column with an index.

Comment