A partial index can e.g. be used to enforce a unique constraint on only a subset of the data.
The rule "a project name must be unique among all active projects" can be enforced with such an index:
create table projects ( project_id integer not null primary key, name varchar(100) not null, is_active boolean; ); create unique index idx_unique_active_name on projects (name) where is_active
With the above definition, the following rows can be inserted
insert into projects (project_id, name, is_active) values (1,'WebShop', true); insert into projects (project_id, name, is_active) values (2,'CRM System', true); insert into projects (project_id, name, is_active) values (3,'WebShop', false);But the following insert will fail:
insert into projects (project_id, name, is_active) values (1,'CRM System', true);
As a side effect the size of the index is reduced if only few rows match the WHERE clause of the index.
More information about partial indexes can be found here: http://use-the-index-luke.com/sql/where-clause/partial-and-filtered-indexes