by jelder · 11mo ago · 0 comments
CREATE INDEX idx_status_gin
ON my_table
USING gin ((data->'status'));
ref: https://www.crunchydata.com/blog/indexing-jsonb-in-postgresIf you can get away with a regular index on either a generated column or an expression, then you absolutely should.
For example, if you want to store settings as JSON, you first have to parse it through e.g. Zod, hope that it isn't failing due to schema changes (or write migrations and hope that succeeds).
When a simple key/value row just works fine, and you can even do partial fetches / updates