Hands-on Lab·PostgreSQL
PostgreSQL Index Types and Index Selection
A partial index is a fifth the size and answers its query in 0.285 ms. A GIN index on the same table produces no improvement at all - 15.9 ms against 16.5 ms - because the predicate matches a third of the rows.
Performance Guide 34 of 47 Advanced
- OSUbuntu 26.04 LTS (resolute)
- PostgreSQL18.6-0ubuntu0.26.04.1
- Test data400,000 rows, 2 core / 4 GB host
- TimeAbout 17 min
- Reviewed27 August 2026
Written against the versions above. GIN is the index type for containment queries on jsonb and arrays. It cannot help extraction predicates like `payload->>'tier' = 'gold'`, which need a btree on the expression instead.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| db-a01 | 192.168.0.81 | Ubuntu 26.04 LTS | Primary / Source / Replica Set Member 1 | 2 Core | 4 GB | 50 GB |
Before you start
- The
eventstable with its jsonb payload column.
-
Index only the rows you query
-
Measure what the partial index does
-
Add a GIN index, and find it does not help