index_advisor

index_advisor

index_advisor : Query index advisor

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
2800
index_advisor
index_advisor
0.2.0
FEAT
PostgreSQL
SQL
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
----d-r
No
No
No
Yes
yes
no
Relationships
Requires
hypopg
See Also
hypopg
pg_qualstats
powa
pg_stat_statements
pg_hint_plan
auto_explain
pg_profile
pg_show_plans

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PIGSTY
0.2.0
18
17
16
15
14
index_advisorhypopg
RPM
PIGSTY
0.2.0
18
17
16
15
14
index_advisor_$v-
DEB
PIGSTY
0.2.0
18
17
16
15
14
postgresql-$v-index-advisor-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
el8.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
el9.x86_64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
el9.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
el10.x86_64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
el10.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
d12.x86_64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
d12.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
d13.x86_64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
d13.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
u22.x86_64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
u22.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
u24.x86_64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
u24.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PackageVersionOSORGSIZEFile URL
index_advisor_180.2.0el8.x86_64pigsty10.2 KiBindex_advisor_18-0.2.0-1PIGSTY.el8.x86_64.rpm
index_advisor_180.2.0el8.aarch64pigsty10.2 KiBindex_advisor_18-0.2.0-1PIGSTY.el8.aarch64.rpm
index_advisor_180.2.0el9.x86_64pigsty10.1 KiBindex_advisor_18-0.2.0-1PIGSTY.el9.x86_64.rpm
index_advisor_180.2.0el9.aarch64pigsty10.1 KiBindex_advisor_18-0.2.0-1PIGSTY.el9.aarch64.rpm
index_advisor_180.2.0el10.x86_64pigsty10.2 KiBindex_advisor_18-0.2.0-1PIGSTY.el10.x86_64.rpm
index_advisor_180.2.0el10.aarch64pigsty10.2 KiBindex_advisor_18-0.2.0-1PIGSTY.el10.aarch64.rpm
postgresql-18-index-advisor0.2.0d12.x86_64pigsty5.6 KiBpostgresql-18-index-advisor_0.2.0-1PIGSTY~bookworm_amd64.deb
postgresql-18-index-advisor0.2.0d12.aarch64pigsty5.6 KiBpostgresql-18-index-advisor_0.2.0-1PIGSTY~bookworm_arm64.deb
postgresql-18-index-advisor0.2.0d13.x86_64pigsty5.6 KiBpostgresql-18-index-advisor_0.2.0-1PIGSTY~trixie_amd64.deb
postgresql-18-index-advisor0.2.0d13.aarch64pigsty5.6 KiBpostgresql-18-index-advisor_0.2.0-1PIGSTY~trixie_arm64.deb
postgresql-18-index-advisor0.2.0u22.x86_64pigsty5.6 KiBpostgresql-18-index-advisor_0.2.0-1PIGSTY~jammy_amd64.deb
postgresql-18-index-advisor0.2.0u22.aarch64pigsty5.6 KiBpostgresql-18-index-advisor_0.2.0-1PIGSTY~jammy_arm64.deb
postgresql-18-index-advisor0.2.0u24.x86_64pigsty5.6 KiBpostgresql-18-index-advisor_0.2.0-1PIGSTY~noble_amd64.deb
postgresql-18-index-advisor0.2.0u24.aarch64pigsty5.6 KiBpostgresql-18-index-advisor_0.2.0-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
index_advisor_170.2.0el8.x86_64pigsty10.2 KiBindex_advisor_17-0.2.0-1PIGSTY.el8.x86_64.rpm
index_advisor_170.2.0el8.aarch64pigsty10.2 KiBindex_advisor_17-0.2.0-1PIGSTY.el8.aarch64.rpm
index_advisor_170.2.0el9.x86_64pigsty10.1 KiBindex_advisor_17-0.2.0-1PIGSTY.el9.x86_64.rpm
index_advisor_170.2.0el9.aarch64pigsty10.1 KiBindex_advisor_17-0.2.0-1PIGSTY.el9.aarch64.rpm
index_advisor_170.2.0el10.x86_64pigsty10.2 KiBindex_advisor_17-0.2.0-1PIGSTY.el10.x86_64.rpm
index_advisor_170.2.0el10.aarch64pigsty10.2 KiBindex_advisor_17-0.2.0-1PIGSTY.el10.aarch64.rpm
postgresql-17-index-advisor0.2.0d12.x86_64pigsty5.6 KiBpostgresql-17-index-advisor_0.2.0-1PIGSTY~bookworm_amd64.deb
postgresql-17-index-advisor0.2.0d12.aarch64pigsty5.6 KiBpostgresql-17-index-advisor_0.2.0-1PIGSTY~bookworm_arm64.deb
postgresql-17-index-advisor0.2.0d13.x86_64pigsty5.6 KiBpostgresql-17-index-advisor_0.2.0-1PIGSTY~trixie_amd64.deb
postgresql-17-index-advisor0.2.0d13.aarch64pigsty5.6 KiBpostgresql-17-index-advisor_0.2.0-1PIGSTY~trixie_arm64.deb
postgresql-17-index-advisor0.2.0u22.x86_64pigsty5.6 KiBpostgresql-17-index-advisor_0.2.0-1PIGSTY~jammy_amd64.deb
postgresql-17-index-advisor0.2.0u22.aarch64pigsty5.6 KiBpostgresql-17-index-advisor_0.2.0-1PIGSTY~jammy_arm64.deb
postgresql-17-index-advisor0.2.0u24.x86_64pigsty5.6 KiBpostgresql-17-index-advisor_0.2.0-1PIGSTY~noble_amd64.deb
postgresql-17-index-advisor0.2.0u24.aarch64pigsty5.6 KiBpostgresql-17-index-advisor_0.2.0-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
index_advisor_160.2.0el8.x86_64pigsty10.2 KiBindex_advisor_16-0.2.0-1PIGSTY.el8.x86_64.rpm
index_advisor_160.2.0el8.aarch64pigsty10.2 KiBindex_advisor_16-0.2.0-1PIGSTY.el8.aarch64.rpm
index_advisor_160.2.0el9.x86_64pigsty10.1 KiBindex_advisor_16-0.2.0-1PIGSTY.el9.x86_64.rpm
index_advisor_160.2.0el9.aarch64pigsty10.1 KiBindex_advisor_16-0.2.0-1PIGSTY.el9.aarch64.rpm
index_advisor_160.2.0el10.x86_64pigsty10.2 KiBindex_advisor_16-0.2.0-1PIGSTY.el10.x86_64.rpm
index_advisor_160.2.0el10.aarch64pigsty10.2 KiBindex_advisor_16-0.2.0-1PIGSTY.el10.aarch64.rpm
postgresql-16-index-advisor0.2.0d12.x86_64pigsty5.6 KiBpostgresql-16-index-advisor_0.2.0-1PIGSTY~bookworm_amd64.deb
postgresql-16-index-advisor0.2.0d12.aarch64pigsty5.6 KiBpostgresql-16-index-advisor_0.2.0-1PIGSTY~bookworm_arm64.deb
postgresql-16-index-advisor0.2.0d13.x86_64pigsty5.6 KiBpostgresql-16-index-advisor_0.2.0-1PIGSTY~trixie_amd64.deb
postgresql-16-index-advisor0.2.0d13.aarch64pigsty5.6 KiBpostgresql-16-index-advisor_0.2.0-1PIGSTY~trixie_arm64.deb
postgresql-16-index-advisor0.2.0u22.x86_64pigsty5.6 KiBpostgresql-16-index-advisor_0.2.0-1PIGSTY~jammy_amd64.deb
postgresql-16-index-advisor0.2.0u22.aarch64pigsty5.6 KiBpostgresql-16-index-advisor_0.2.0-1PIGSTY~jammy_arm64.deb
postgresql-16-index-advisor0.2.0u24.x86_64pigsty5.6 KiBpostgresql-16-index-advisor_0.2.0-1PIGSTY~noble_amd64.deb
postgresql-16-index-advisor0.2.0u24.aarch64pigsty5.6 KiBpostgresql-16-index-advisor_0.2.0-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
index_advisor_150.2.0el8.x86_64pigsty10.2 KiBindex_advisor_15-0.2.0-1PIGSTY.el8.x86_64.rpm
index_advisor_150.2.0el8.aarch64pigsty10.2 KiBindex_advisor_15-0.2.0-1PIGSTY.el8.aarch64.rpm
index_advisor_150.2.0el9.x86_64pigsty10.1 KiBindex_advisor_15-0.2.0-1PIGSTY.el9.x86_64.rpm
index_advisor_150.2.0el9.aarch64pigsty10.1 KiBindex_advisor_15-0.2.0-1PIGSTY.el9.aarch64.rpm
index_advisor_150.2.0el10.x86_64pigsty10.2 KiBindex_advisor_15-0.2.0-1PIGSTY.el10.x86_64.rpm
index_advisor_150.2.0el10.aarch64pigsty10.2 KiBindex_advisor_15-0.2.0-1PIGSTY.el10.aarch64.rpm
postgresql-15-index-advisor0.2.0d12.x86_64pigsty5.6 KiBpostgresql-15-index-advisor_0.2.0-1PIGSTY~bookworm_amd64.deb
postgresql-15-index-advisor0.2.0d12.aarch64pigsty5.6 KiBpostgresql-15-index-advisor_0.2.0-1PIGSTY~bookworm_arm64.deb
postgresql-15-index-advisor0.2.0d13.x86_64pigsty5.6 KiBpostgresql-15-index-advisor_0.2.0-1PIGSTY~trixie_amd64.deb
postgresql-15-index-advisor0.2.0d13.aarch64pigsty5.6 KiBpostgresql-15-index-advisor_0.2.0-1PIGSTY~trixie_arm64.deb
postgresql-15-index-advisor0.2.0u22.x86_64pigsty5.6 KiBpostgresql-15-index-advisor_0.2.0-1PIGSTY~jammy_amd64.deb
postgresql-15-index-advisor0.2.0u22.aarch64pigsty5.6 KiBpostgresql-15-index-advisor_0.2.0-1PIGSTY~jammy_arm64.deb
postgresql-15-index-advisor0.2.0u24.x86_64pigsty5.6 KiBpostgresql-15-index-advisor_0.2.0-1PIGSTY~noble_amd64.deb
postgresql-15-index-advisor0.2.0u24.aarch64pigsty5.6 KiBpostgresql-15-index-advisor_0.2.0-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
index_advisor_140.2.0el8.x86_64pigsty10.2 KiBindex_advisor_14-0.2.0-1PIGSTY.el8.x86_64.rpm
index_advisor_140.2.0el8.aarch64pigsty10.2 KiBindex_advisor_14-0.2.0-1PIGSTY.el8.aarch64.rpm
index_advisor_140.2.0el9.x86_64pigsty10.1 KiBindex_advisor_14-0.2.0-1PIGSTY.el9.x86_64.rpm
index_advisor_140.2.0el9.aarch64pigsty10.1 KiBindex_advisor_14-0.2.0-1PIGSTY.el9.aarch64.rpm
index_advisor_140.2.0el10.x86_64pigsty10.2 KiBindex_advisor_14-0.2.0-1PIGSTY.el10.x86_64.rpm
index_advisor_140.2.0el10.aarch64pigsty10.2 KiBindex_advisor_14-0.2.0-1PIGSTY.el10.aarch64.rpm
postgresql-14-index-advisor0.2.0d12.x86_64pigsty5.6 KiBpostgresql-14-index-advisor_0.2.0-1PIGSTY~bookworm_amd64.deb
postgresql-14-index-advisor0.2.0d12.aarch64pigsty5.6 KiBpostgresql-14-index-advisor_0.2.0-1PIGSTY~bookworm_arm64.deb
postgresql-14-index-advisor0.2.0d13.x86_64pigsty5.6 KiBpostgresql-14-index-advisor_0.2.0-1PIGSTY~trixie_amd64.deb
postgresql-14-index-advisor0.2.0d13.aarch64pigsty5.6 KiBpostgresql-14-index-advisor_0.2.0-1PIGSTY~trixie_arm64.deb
postgresql-14-index-advisor0.2.0u22.x86_64pigsty5.6 KiBpostgresql-14-index-advisor_0.2.0-1PIGSTY~jammy_amd64.deb
postgresql-14-index-advisor0.2.0u22.aarch64pigsty5.6 KiBpostgresql-14-index-advisor_0.2.0-1PIGSTY~jammy_arm64.deb
postgresql-14-index-advisor0.2.0u24.x86_64pigsty5.6 KiBpostgresql-14-index-advisor_0.2.0-1PIGSTY~noble_amd64.deb
postgresql-14-index-advisor0.2.0u24.aarch64pigsty5.6 KiBpostgresql-14-index-advisor_0.2.0-1PIGSTY~noble_arm64.deb

Source

pig build pkg index_advisor;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install index_advisor;		# install via package name, for the active PG version

pig install index_advisor -v 18;   # install for PG 18
pig install index_advisor -v 17;   # install for PG 17
pig install index_advisor -v 16;   # install for PG 16
pig install index_advisor -v 15;   # install for PG 15
pig install index_advisor -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION index_advisor CASCADE; -- requires hypopg

Usage

index_advisor: Query index advisor

index_advisor analyzes a SQL query and recommends indexes that would improve its execution time, reporting before/after cost estimates and the DDL statements to create the suggested indexes.

Function

index_advisor(query text)
RETURNS TABLE (
    startup_cost_before jsonb,
    startup_cost_after  jsonb,
    total_cost_before   jsonb,
    total_cost_after    jsonb,
    index_statements    text[],
    errors              text[]
)

Basic Example

CREATE TABLE book (
    id    int  PRIMARY KEY,
    title text NOT NULL
);

SELECT * FROM index_advisor('
    SELECT book.id FROM book WHERE title = $1
');

Returns cost improvements and the recommended CREATE INDEX statement.

Multi-Table Example

SELECT * FROM index_advisor('
    SELECT book.id, book.title, publisher.name, author.name, review.body
    FROM book
    JOIN publisher ON book.publisher_id = publisher.id
    JOIN author    ON book.author_id = author.id
    JOIN review    ON book.id = review.book_id
    WHERE author.id = $1 AND publisher.id = $2
');

The output includes multiple index recommendations across the joined tables with before/after cost comparisons.

Features

  • Supports parameterized queries using $1, $2 syntax
  • Handles materialized views
  • Resolves underlying tables and columns behind views
  • Depends on HypoPG for hypothetical index evaluation
Last updated on