Skip to main content

Partial, GIN, GiST and Hash indexes — when to use each

When should you reach for a partial index or GIN index instead of a standard B-tree?

Official Reference

Model Answer & Explanation

Use a partial index (e.g. WHERE status = 'pending' or WHERE deleted_at IS NULL) to keep index size tiny and writes fast when queries consistently filter on that predicate. Use GIN for multi-value containment: JSONB (@>), arrays, and full-text tsvector (@@). Use GiST for ranges, geometry, and pg_trgm/nearest-neighbor.

Follow-up Interview Question · Why must a query’s WHERE clause imply the partial index’s predicate for Postgres to use it?

Module Context & References

PostgreSQL & Redis · Popular interview theory High-yield indexing, MVCC, query plan and Redis caching questions
Personal Notes · Markdown

Technologies & Interview Topics Covered

Switch between short-term interview tracks and long-term 80/20 engineering depth to practice JavaScript internals, React rendering and hooks, timed frontend machine coding UI challenges, MeetaPro FG300, Blind 75 & NeetCode 150 DSA patterns, Python & FastAPI APIs, PostgreSQL query optimization & MVCC, Redis caching, Applied AI RAG pipelines & evaluations, and distributed system design.