Small. Fast. Reliable.
Choose any three.
Partial Indexes
Table Of Contents

1. Introduction

A partial index is an index over a subset of the rows of a table.

In ordinary indexes, there is exactly one entry in the index for every row in the table. In partial indexes, only some subset of the rows in the table have corresponding index entries. For example, a partial index might omit entries for which the column being indexed is NULL. When used judiciously, partial indexes can result in smaller database files and improvements in both query and write performance.

2. Creating Partial Indexes

Create a partial index by adding a WHERE clause to the end of an ordinary CREATE INDEX statement.

create-index-stmt:

CREATE UNIQUE INDEX IF NOT EXISTS schema-name . index-name ON table-name ( indexed-column ) , WHERE expr

expr: