I am doing a performance tuning on one of the largest table in our project. While reading about indexes I came across partial indexes. This sounds like a very nice idea to include only rows which are getting accessed frequently.
But I am not able to figure out how a partial index gets updated. For example, I have a table with following columns:
task_uuid, job_id, enqueued_at, updated_at, task_status
task_status
can be: ENQUEUED, RUNNING, ASSIGNED, FAILED.
We search for the records which are in ENQUEUED
state very frequently. If we add a partial index on (task_uuid, task_status)
it will build a unique key and improve the performance. But what happens when the row gets updated to RUNNING
status? (task_uuid, task_status)
is still unique, but will it be removed from the partial index? The record does not fulfill the condition any more.