Skip to content

online_advisor

Suggest missing indexes and extended statistics online

online_advisor · Suggest missing indexes and extended statistics online

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
5270online_advisoronline_advisor1.0ADMINPostgreSQLC
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--sLd-rNoYesYesYesyesno
Requires shared_preload_libraries=online_advisor on PostgreSQL 14-16; PGSTY backports upstream PG18 hook compatibility.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY1.019 18 17 16 15online_advisor-
RPMPIGSTY1.019 18 17 16 15online_advisor_$v-
DEBPIGSTY1.019 18 17 16 15postgresql-$v-online-advisor-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el8.aarch64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el9.x86_64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el9.aarch64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el10.x86_64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el10.aarch64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
d12.x86_64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
d12.aarch64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
d13.x86_64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
d13.aarch64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u22.x86_64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u22.aarch64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u24.x86_64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u24.aarch64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u26.x86_64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u26.aarch64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
PackageVersionOSORGSIZEFile URL
online_advisor_181.0el8.x86_64pigsty38.7 KiBonline_advisor_18-1.0-1PGSTY.el8.x86_64.rpm
online_advisor_181.0el8.aarch64pigsty37.9 KiBonline_advisor_18-1.0-1PGSTY.el8.aarch64.rpm
online_advisor_181.0el9.x86_64pigsty39.3 KiBonline_advisor_18-1.0-1PGSTY.el9.x86_64.rpm
online_advisor_181.0el9.aarch64pigsty38.7 KiBonline_advisor_18-1.0-1PGSTY.el9.aarch64.rpm
online_advisor_181.0el10.x86_64pigsty39.7 KiBonline_advisor_18-1.0-1PGSTY.el10.x86_64.rpm
online_advisor_181.0el10.aarch64pigsty39.2 KiBonline_advisor_18-1.0-1PGSTY.el10.aarch64.rpm
postgresql-18-online-advisor1.0d12.x86_64pigsty30.6 KiBpostgresql-18-online-advisor_1.0-1PGSTY~bookworm_amd64.deb
postgresql-18-online-advisor1.0d12.aarch64pigsty29.5 KiBpostgresql-18-online-advisor_1.0-1PGSTY~bookworm_arm64.deb
postgresql-18-online-advisor1.0d13.x86_64pigsty30.7 KiBpostgresql-18-online-advisor_1.0-1PGSTY~trixie_amd64.deb
postgresql-18-online-advisor1.0d13.aarch64pigsty29.7 KiBpostgresql-18-online-advisor_1.0-1PGSTY~trixie_arm64.deb
postgresql-18-online-advisor1.0u22.x86_64pigsty32.8 KiBpostgresql-18-online-advisor_1.0-1PGSTY~jammy_amd64.deb
postgresql-18-online-advisor1.0u22.aarch64pigsty32.1 KiBpostgresql-18-online-advisor_1.0-1PGSTY~jammy_arm64.deb
postgresql-18-online-advisor1.0u24.x86_64pigsty32.0 KiBpostgresql-18-online-advisor_1.0-1PGSTY~noble_amd64.deb
postgresql-18-online-advisor1.0u24.aarch64pigsty31.0 KiBpostgresql-18-online-advisor_1.0-1PGSTY~noble_arm64.deb
postgresql-18-online-advisor1.0u26.x86_64pigsty31.8 KiBpostgresql-18-online-advisor_1.0-1PGSTY~resolute_amd64.deb
postgresql-18-online-advisor1.0u26.aarch64pigsty31.2 KiBpostgresql-18-online-advisor_1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
online_advisor_171.0el8.x86_64pigsty38.8 KiBonline_advisor_17-1.0-1PGSTY.el8.x86_64.rpm
online_advisor_171.0el8.aarch64pigsty37.9 KiBonline_advisor_17-1.0-1PGSTY.el8.aarch64.rpm
online_advisor_171.0el9.x86_64pigsty39.3 KiBonline_advisor_17-1.0-1PGSTY.el9.x86_64.rpm
online_advisor_171.0el9.aarch64pigsty38.7 KiBonline_advisor_17-1.0-1PGSTY.el9.aarch64.rpm
online_advisor_171.0el10.x86_64pigsty39.7 KiBonline_advisor_17-1.0-1PGSTY.el10.x86_64.rpm
online_advisor_171.0el10.aarch64pigsty39.2 KiBonline_advisor_17-1.0-1PGSTY.el10.aarch64.rpm
postgresql-17-online-advisor1.0d12.x86_64pigsty30.6 KiBpostgresql-17-online-advisor_1.0-1PGSTY~bookworm_amd64.deb
postgresql-17-online-advisor1.0d12.aarch64pigsty29.5 KiBpostgresql-17-online-advisor_1.0-1PGSTY~bookworm_arm64.deb
postgresql-17-online-advisor1.0d13.x86_64pigsty30.7 KiBpostgresql-17-online-advisor_1.0-1PGSTY~trixie_amd64.deb
postgresql-17-online-advisor1.0d13.aarch64pigsty29.7 KiBpostgresql-17-online-advisor_1.0-1PGSTY~trixie_arm64.deb
postgresql-17-online-advisor1.0u22.x86_64pigsty38.2 KiBpostgresql-17-online-advisor_1.0-1PGSTY~jammy_amd64.deb
postgresql-17-online-advisor1.0u22.aarch64pigsty37.3 KiBpostgresql-17-online-advisor_1.0-1PGSTY~jammy_arm64.deb
postgresql-17-online-advisor1.0u24.x86_64pigsty32.0 KiBpostgresql-17-online-advisor_1.0-1PGSTY~noble_amd64.deb
postgresql-17-online-advisor1.0u24.aarch64pigsty31.0 KiBpostgresql-17-online-advisor_1.0-1PGSTY~noble_arm64.deb
postgresql-17-online-advisor1.0u26.x86_64pigsty31.7 KiBpostgresql-17-online-advisor_1.0-1PGSTY~resolute_amd64.deb
postgresql-17-online-advisor1.0u26.aarch64pigsty31.2 KiBpostgresql-17-online-advisor_1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
online_advisor_161.0el8.x86_64pigsty38.8 KiBonline_advisor_16-1.0-1PGSTY.el8.x86_64.rpm
online_advisor_161.0el8.aarch64pigsty37.7 KiBonline_advisor_16-1.0-1PGSTY.el8.aarch64.rpm
online_advisor_161.0el9.x86_64pigsty39.4 KiBonline_advisor_16-1.0-1PGSTY.el9.x86_64.rpm
online_advisor_161.0el9.aarch64pigsty38.6 KiBonline_advisor_16-1.0-1PGSTY.el9.aarch64.rpm
online_advisor_161.0el10.x86_64pigsty39.6 KiBonline_advisor_16-1.0-1PGSTY.el10.x86_64.rpm
online_advisor_161.0el10.aarch64pigsty39.1 KiBonline_advisor_16-1.0-1PGSTY.el10.aarch64.rpm
postgresql-16-online-advisor1.0d12.x86_64pigsty30.6 KiBpostgresql-16-online-advisor_1.0-1PGSTY~bookworm_amd64.deb
postgresql-16-online-advisor1.0d12.aarch64pigsty29.8 KiBpostgresql-16-online-advisor_1.0-1PGSTY~bookworm_arm64.deb
postgresql-16-online-advisor1.0d13.x86_64pigsty30.8 KiBpostgresql-16-online-advisor_1.0-1PGSTY~trixie_amd64.deb
postgresql-16-online-advisor1.0d13.aarch64pigsty30.0 KiBpostgresql-16-online-advisor_1.0-1PGSTY~trixie_arm64.deb
postgresql-16-online-advisor1.0u22.x86_64pigsty38.2 KiBpostgresql-16-online-advisor_1.0-1PGSTY~jammy_amd64.deb
postgresql-16-online-advisor1.0u22.aarch64pigsty37.5 KiBpostgresql-16-online-advisor_1.0-1PGSTY~jammy_arm64.deb
postgresql-16-online-advisor1.0u24.x86_64pigsty32.0 KiBpostgresql-16-online-advisor_1.0-1PGSTY~noble_amd64.deb
postgresql-16-online-advisor1.0u24.aarch64pigsty31.3 KiBpostgresql-16-online-advisor_1.0-1PGSTY~noble_arm64.deb
postgresql-16-online-advisor1.0u26.x86_64pigsty31.9 KiBpostgresql-16-online-advisor_1.0-1PGSTY~resolute_amd64.deb
postgresql-16-online-advisor1.0u26.aarch64pigsty31.0 KiBpostgresql-16-online-advisor_1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
online_advisor_151.0el8.x86_64pigsty38.8 KiBonline_advisor_15-1.0-1PGSTY.el8.x86_64.rpm
online_advisor_151.0el8.aarch64pigsty37.7 KiBonline_advisor_15-1.0-1PGSTY.el8.aarch64.rpm
online_advisor_151.0el9.x86_64pigsty39.4 KiBonline_advisor_15-1.0-1PGSTY.el9.x86_64.rpm
online_advisor_151.0el9.aarch64pigsty38.5 KiBonline_advisor_15-1.0-1PGSTY.el9.aarch64.rpm
online_advisor_151.0el10.x86_64pigsty39.6 KiBonline_advisor_15-1.0-1PGSTY.el10.x86_64.rpm
online_advisor_151.0el10.aarch64pigsty39.1 KiBonline_advisor_15-1.0-1PGSTY.el10.aarch64.rpm
postgresql-15-online-advisor1.0d12.x86_64pigsty30.7 KiBpostgresql-15-online-advisor_1.0-1PGSTY~bookworm_amd64.deb
postgresql-15-online-advisor1.0d12.aarch64pigsty29.8 KiBpostgresql-15-online-advisor_1.0-1PGSTY~bookworm_arm64.deb
postgresql-15-online-advisor1.0d13.x86_64pigsty30.7 KiBpostgresql-15-online-advisor_1.0-1PGSTY~trixie_amd64.deb
postgresql-15-online-advisor1.0d13.aarch64pigsty30.0 KiBpostgresql-15-online-advisor_1.0-1PGSTY~trixie_arm64.deb
postgresql-15-online-advisor1.0u22.x86_64pigsty38.0 KiBpostgresql-15-online-advisor_1.0-1PGSTY~jammy_amd64.deb
postgresql-15-online-advisor1.0u22.aarch64pigsty37.4 KiBpostgresql-15-online-advisor_1.0-1PGSTY~jammy_arm64.deb
postgresql-15-online-advisor1.0u24.x86_64pigsty31.9 KiBpostgresql-15-online-advisor_1.0-1PGSTY~noble_amd64.deb
postgresql-15-online-advisor1.0u24.aarch64pigsty31.3 KiBpostgresql-15-online-advisor_1.0-1PGSTY~noble_arm64.deb
postgresql-15-online-advisor1.0u26.x86_64pigsty31.9 KiBpostgresql-15-online-advisor_1.0-1PGSTY~resolute_amd64.deb
postgresql-15-online-advisor1.0u26.aarch64pigsty31.0 KiBpostgresql-15-online-advisor_1.0-1PGSTY~resolute_arm64.deb

Source

pig build pkg online_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 online_advisor;		# install by package name

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

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'online_advisor';

Create this extension with:

CREATE EXTENSION online_advisor;

Usage

Sources:

online_advisor observes PostgreSQL execution plans and workload timing, then recommends indexes, extended statistics, or prepared statements. It reports candidates only; it never creates an index or statistics object automatically.

Core Workflow

Preload the library and restart PostgreSQL:

shared_preload_libraries = 'online_advisor'

Create and activate the extension in each database whose workload should be observed:

CREATE EXTENSION online_advisor;

-- Calling an extension function activates collection in this database.
SELECT get_executor_stats();

After representative workload has run, inspect the recommendations:

SELECT * FROM proposed_indexes;
SELECT * FROM proposed_statistics;
SELECT * FROM get_executor_stats();

-- Keep separate index candidates instead of combining compatible clauses.
SELECT * FROM propose_indexes(combine => false);

Review each generated create_index or create_statistics statement before applying it. Run ANALYZE after creating an index or statistics object so the planner can use current statistics.

Objects and Settings

  • proposed_indexes: view over propose_indexes(combine, reset) with filtering volume, call count, elapsed time, and a candidate CREATE INDEX statement.
  • proposed_statistics: view over propose_statistics(combine, reset) with misestimation, call count, elapsed time, and a candidate CREATE STATISTICS statement.
  • get_executor_stats(reset): returns aggregate planning and execution time, query count, and planning-overhead ratios.
  • online_advisor.filtered_threshold: minimum filtered-row count considered for an index proposal; default 1000.
  • online_advisor.misestimation_threshold: actual-to-estimated row ratio considered for statistics; default 10.
  • online_advisor.min_rows: minimum returned rows for misestimation analysis; default 1000.
  • online_advisor.max_index_proposals and online_advisor.max_stat_proposals: proposal capacities; set them before the extension is activated.
  • online_advisor.do_instrumentation, online_advisor.log_duration, and online_advisor.prepare_threshold: control collection and prepared-statement advice.

Caveats

  • Instrumentation adds workload overhead; measure it on the target system and disable collection when it is not needed.
  • The index heuristic does not reason about operator ordering in compound indexes, join indexes, or indexes used only to avoid sorting.
  • The extension does not estimate the benefit of a proposed index. Use plan review or a hypothetical-index tool before building expensive indexes.
  • Advice is database-local and depends on the workload observed since activation or reset.

Table reader