Your PostgreSQL table has 50 million orders.
But your operational query may care about only the small number still PENDING.
Why maintain an index entry for every completed order?
That's where a Partial Index becomes interesting.
CREATE INDEX idx_orders_pending
ON orders (created_at)
WHERE status = 'PENDING';
The table still contains everything.
The index doesn't have to.
The same idea can be useful for:
π E-commerce β orders still requiring processing
π¦ Parcel delivery β parcels not yet delivered
π³ Payments β transactions not yet settled
But there's an important catch:
PostgreSQL can use the partial index only when the planner can establish that the query's conditions imply the index predicate.
So don't add one because it sounds efficient.
Measure the data distribution. Examine the query plan. Test it against the real workload.
Sometimes better indexing isn't about indexing more.
It's about deliberately indexing less.
For further actions, you may consider blocking this person and/or reporting abuse

Top comments (1)
Some comments may only be visible to logged-in visitors. Sign in to view all comments. Some comments have been hidden by the post's author - find out more