Skip to content

pg_fk_indexer

Automatically creates indexes for newly defined foreign-key columns.

pg_fk_indexer · Automatically creates indexes for newly defined foreign-key columns.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
101910pg_fk_indexerpg_fk_indexer1.0ADMINPostgreSQLC

Usage

Sources:

pg_fk_indexer Automatically creates indexes for newly defined foreign-key columns.

Enablement

Merge pg_fk_indexer into the existing preload list, restart PostgreSQL, and then create pg_fk_indexer in each database that needs its SQL objects:

shared_preload_libraries = 'pg_fk_indexer'
CREATE EXTENSION pg_fk_indexer;

Core Workflow

The following example is taken from the reviewed upstream documentation. Adapt object names, paths, credentials, and workload values before use.

-- Foreign keys are now auto-indexed
CREATE TABLE users (id int PRIMARY KEY, username text);
CREATE TABLE orders (user_id int REFERENCES users(id));
--  index on orders(user_id) is created automatically

Main Objects

The official sources define the extension surface dynamically or through provider tooling; inspect the installed version before granting access.

Operations and Boundaries

  • Preloading pg_fk_indexer changes cluster startup state; stage configuration and restart changes separately from CREATE EXTENSION.

Table reader