Partial Indexes
Specifying the WHERE
clause in the index creation statement creates a partial index (also knows as filtered index).A partial index contains only rows that match the search condition of the WHERE
.
A partial index definition may include the UNIQUE
clause.In this case, every key in the index is required to be unique.This allows enforcing uniqueness for a subset of table rows.
A partial index is usable only in the following cases:
-
The
WHERE
clause of the statement includes exactly the same boolean expression as the one defined for the index; -
The search condition defined for the index contains ORed boolean expressions and one of them is explicitly included in the
WHERE
clause of the statement; -
The search condition defined for the index specifies
IS NOT NULL
and theWHERE
clause of the statement includes an expression on the same field that is known to exclude NULLs.