PostgreSQL has partial indexes Show archive.org snapshot . With a partial index you tell Postgres to only index rows matching a given query.
Some uses cases for a partial index:
The linked article Show archive.org snapshot shows how to create a partial index with Rails.