Rails: Postgres Partial Indexing

Posted . Visible to the public.

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:

  • You want a uniqueness index, but only under some conditions
  • Your table is very large and indexing every row becomes expensive

The linked article Show archive.org snapshot shows how to create a partial index with Rails.

Profile picture of Henning Koch
Henning Koch
Last edit
Henning Koch
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2021-01-25 14:48)