Should I store user settings as JSONB or as real columns

Back to list2024-06-02
You

Should I store user settings as JSONB or as real columns?

ChatGPT

Columns for anything you filter or join on, JSONB for the long tail nobody queries. The moment you write a WHERE settings->>'plan' = ... that runs often, that key has earned a column and an index.

You
monthly-requests.png
You

timestamptz or timestamp for event times?

ChatGPT

timestamptz almost always. It stores a point in time in UTC and converts on the way out; timestamp stores a wall clock reading with no idea which wall it was on, which becomes unrecoverable once daylight saving moves.