A table retains years of history, while the application mostly reads the few jobs still waiting. Indexing every row identically is not always the only option. A partial index can target a condition-defined subset, but it is not an automatic optimisation.
The PostgreSQL documentation explains predicates and limitations. This article was checked on November 12, 2026. It does not describe a feature introduced this week or claim benchmark results for your database.
Begin with an observed query
Consider this illustrative read against a fictional jobs table:
SELECT id, created_at
FROM jobs
WHERE status = 'pending'
ORDER BY created_at
LIMIT 50;
Start with a query actually used, including volumes and frequency. Here, the team needs to understand how many jobs remain pending and how that population changes rather than assuming it is always small.
The query is read-only, but names and data model are examples. Do not copy it against a real table assuming it describes your application.
Our recommendation is to document the expected result as well as elapsed time. Faster retrieval of the wrong jobs would not validate an optimisation.
Check the predicate against actual requirements
The planner must recognise that the query condition implies the index predicate. Different expressions and some prepared-query parameters can prevent that recognition.
Test SQL actually sent by the application, not only a simplified version entered manually. Parameters, ordering and additional filters can change the observation.
An index specialised for pending work is not a general solution for every historical search. Identify workflows expected to benefit and those outside its scope.
Measure more than one read
Compare representative data using the same parameters before and after. Record duration, plan and behaviour during status transitions.
A job moving out of pending can change membership of the indexed subset. Compare reading benefits with writing and maintenance costs rather than judging from one screenshot.
Include a scenario where the queue grows substantially. An assumption valid on a normal day may fail when recovering hours of accumulated work.
Keep measurements alongside their conditions. Another person should be able to repeat the comparison rather than merely trusting a reported improvement.
Treat creation as a migration
The CREATE INDEX command has distinct modes and constraints. This article does not provide a universal production creation command.
Agree on the window, resources and failure behaviour with the database owner. Concurrent creation should not be interpreted as a promise of no waiting or operational impact whatsoever.
Verify the resulting state and how the migration tool records it. An interrupted attempt should not be concealed by an unexplained manual registry change.
Keep the decision reviewable
Retain the index's purpose, associated queries and measurements. That supports reassessment when the product changes or historical data is archived.
If performance does not improve, examine other causes rather than accumulating indexes. A lock wait requires a different investigation.
Our EXPLAIN and BUFFERS guide helps interpret plans, while the migration-wait article examines blocking. Optimisation begins with precise observation; a smaller index alone is not evidence of success.
Cover visual: generated editorial illustration, not an official screenshot.




Join the discussion
Comments
Loading comments…