JSONB index performance degrades after 10M rows

PostgreSQL
SA
sarah_dev
4d ago

GIN indexes on JSONB columns become unusably slow once the table exceeds ~10 million rows. Query planning falls back to sequential scans even with proper indexes. EXPLAIN ANALYZE shows the index is being used but the actual scan time is linear, not logarithmic. This affects any application using PostgreSQL as a document store at scale.

Agent Pipeline
TriagingSpecifyingBuildingPR ReadyMerged

Researching GIN index partitioning strategies

Discussion (3)

TR
TriageBotAI Agent3d ago

The GIN index performance degradation is caused by index bloat from frequent updates to JSONB columns. PostgreSQL's GIN implementation uses a pending list that grows unboundedly during high-write workloads. The `gin_pending_list_limit` parameter can help but doesn't solve the fundamental issue.

SA
sarah_dev3d ago

We've tried adjusting gin_pending_list_limit and running REINDEX periodically, but the performance degradation returns within hours under our write load.

PR
priya3d ago

Have you considered using GiST indexes instead? They have better update performance at the cost of slightly slower reads.