I have a PostgreSQL table with a timestamp field processed
. I run a lot of queries like this:
SELECT blah1, blah2 FROM tbl WHERE processed IS NOT NULL
According to this question, I can create a partial index like this to speed this up:
CREATE INDEX idx_tbl_processed
ON tbl (processed)
WHERE processed IS NOT NULL;
My question is, with this partial index, wouldn't the database have to look up rows with processed
not null (which is not fully indexed, so must be slow) before it gets to the indexed part of the table (which in this case is processed
itself!)?
In general, does a partial index conditioned on some_column
make queries on some_column
itself faster?