hypopg

hypopg : Hypothetical indexes for PostgreSQL

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
2790
hypopg
hypopg
1.4.2
FEAT
PostgreSQL
C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-r
No
Yes
No
Yes
yes
no
Relationships
See Also
index_advisor
pg_qualstats
powa
pg_hint_plan
auto_explain
pg_stat_statements
btree_gin
pg_show_plans

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PGDG
1.4.2
18
17
16
15
14
hypopg-
RPM
PGDG
1.4.2
18
17
16
15
14
hypopg_$v-
DEB
PGDG
1.4.2
18
17
16
15
14
postgresql-$v-hypopg-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PGDG 1.4.2
PGDG 1.4.1
PGDG 1.4.1
PGDG 1.4.1
PGDG 1.4.1
el8.aarch64
PGDG 1.4.2
PGDG 1.4.1
PGDG 1.4.1
PGDG 1.4.1
PGDG 1.4.1
el9.x86_64
PGDG 1.4.2
PGDG 1.4.1
PGDG 1.4.1
PGDG 1.4.1
PGDG 1.4.1
el9.aarch64
PGDG 1.4.2
PGDG 1.4.1
PGDG 1.4.1
PGDG 1.4.1
PGDG 1.4.1
el10.x86_64
PGDG 1.4.2
PGDG 1.4.1
PGDG 1.4.1
PGDG 1.4.1
PGDG 1.4.1
el10.aarch64
PGDG 1.4.2
PGDG 1.4.1
PGDG 1.4.1
PGDG 1.4.1
PGDG 1.4.1
d12.x86_64
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
d12.aarch64
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
d13.x86_64
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
d13.aarch64
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
u22.x86_64
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
u22.aarch64
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
u24.x86_64
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
u24.aarch64
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
PGDG 1.4.2
PackageVersionOSORGSIZEFile URL
hypopg_161.4.1el8.x86_64pgdg30.1 KiBhypopg_16-1.4.1-1PGDG.rhel8.x86_64.rpm
hypopg_161.4.0el8.x86_64pgdg29.6 KiBhypopg_16-1.4.0-2PGDG.rhel8.x86_64.rpm
hypopg_161.4.1el8.aarch64pgdg30.9 KiBhypopg_16-1.4.1-1PGDG.rhel8.aarch64.rpm
hypopg_161.4.0el8.aarch64pgdg30.3 KiBhypopg_16-1.4.0-2PGDG.rhel8.aarch64.rpm
hypopg_161.4.1el9.x86_64pgdg28.9 KiBhypopg_16-1.4.1-1PGDG.rhel9.x86_64.rpm
hypopg_161.4.0el9.x86_64pgdg28.4 KiBhypopg_16-1.4.0-2PGDG.rhel9.x86_64.rpm
hypopg_161.4.1el9.aarch64pgdg30.3 KiBhypopg_16-1.4.1-1PGDG.rhel9.aarch64.rpm
hypopg_161.4.0el9.aarch64pgdg29.7 KiBhypopg_16-1.4.0-2PGDG.rhel9.aarch64.rpm
hypopg_161.4.1el10.x86_64pgdg30.2 KiBhypopg_16-1.4.1-3PGDG.rhel10.x86_64.rpm
hypopg_161.4.1el10.aarch64pgdg31.9 KiBhypopg_16-1.4.1-3PGDG.rhel10.aarch64.rpm
postgresql-16-hypopg1.4.2d12.x86_64pgdg57.4 KiBpostgresql-16-hypopg_1.4.2-2.pgdg12+1_amd64.deb
postgresql-16-hypopg1.4.2d12.aarch64pgdg58.1 KiBpostgresql-16-hypopg_1.4.2-2.pgdg12+1_arm64.deb
postgresql-16-hypopg1.4.2d13.x86_64pgdg57.7 KiBpostgresql-16-hypopg_1.4.2-2.pgdg13+1_amd64.deb
postgresql-16-hypopg1.4.2d13.aarch64pgdg58.5 KiBpostgresql-16-hypopg_1.4.2-2.pgdg13+1_arm64.deb
postgresql-16-hypopg1.4.2u22.x86_64pgdg72.0 KiBpostgresql-16-hypopg_1.4.2-2.pgdg22.04+1_amd64.deb
postgresql-16-hypopg1.4.2u22.aarch64pgdg72.0 KiBpostgresql-16-hypopg_1.4.2-2.pgdg22.04+1_arm64.deb
postgresql-16-hypopg1.4.2u24.x86_64pgdg57.3 KiBpostgresql-16-hypopg_1.4.2-2.pgdg24.04+1_amd64.deb
postgresql-16-hypopg1.4.2u24.aarch64pgdg57.7 KiBpostgresql-16-hypopg_1.4.2-2.pgdg24.04+1_arm64.deb
PackageVersionOSORGSIZEFile URL
hypopg_151.4.1el8.x86_64pgdg30.5 KiBhypopg_15-1.4.1-1PGDG.rhel8.x86_64.rpm
hypopg_151.4.0el8.x86_64pgdg29.8 KiBhypopg_15-1.4.0-1.rhel8.x86_64.rpm
hypopg_151.3.1el8.x86_64pgdg74.8 KiBhypopg_15-1.3.1-1.rhel8.x86_64.rpm
hypopg_151.4.1el8.aarch64pgdg31.1 KiBhypopg_15-1.4.1-1PGDG.rhel8.aarch64.rpm
hypopg_151.4.0el8.aarch64pgdg30.3 KiBhypopg_15-1.4.0-1.rhel8.aarch64.rpm
hypopg_151.3.1el8.aarch64pgdg74.8 KiBhypopg_15-1.3.1-1.rhel8.aarch64.rpm
hypopg_151.4.1el9.x86_64pgdg29.8 KiBhypopg_15-1.4.1-1PGDG.rhel9.x86_64.rpm
hypopg_151.4.0el9.x86_64pgdg29.1 KiBhypopg_15-1.4.0-1.rhel9.x86_64.rpm
hypopg_151.3.1el9.x86_64pgdg75.6 KiBhypopg_15-1.3.1-1.rhel9.x86_64.rpm
hypopg_151.4.1el9.aarch64pgdg31.2 KiBhypopg_15-1.4.1-1PGDG.rhel9.aarch64.rpm
hypopg_151.4.0el9.aarch64pgdg30.5 KiBhypopg_15-1.4.0-1.rhel9.aarch64.rpm
hypopg_151.3.1el9.aarch64pgdg76.2 KiBhypopg_15-1.3.1-1.rhel9.aarch64.rpm
hypopg_151.4.1el10.x86_64pgdg31.1 KiBhypopg_15-1.4.1-3PGDG.rhel10.x86_64.rpm
hypopg_151.4.1el10.aarch64pgdg32.8 KiBhypopg_15-1.4.1-3PGDG.rhel10.aarch64.rpm
postgresql-15-hypopg1.4.2d12.x86_64pgdg57.9 KiBpostgresql-15-hypopg_1.4.2-2.pgdg12+1_amd64.deb
postgresql-15-hypopg1.4.2d12.aarch64pgdg58.1 KiBpostgresql-15-hypopg_1.4.2-2.pgdg12+1_arm64.deb
postgresql-15-hypopg1.4.2d13.x86_64pgdg58.0 KiBpostgresql-15-hypopg_1.4.2-2.pgdg13+1_amd64.deb
postgresql-15-hypopg1.4.2d13.aarch64pgdg58.7 KiBpostgresql-15-hypopg_1.4.2-2.pgdg13+1_arm64.deb
postgresql-15-hypopg1.4.2u22.x86_64pgdg72.5 KiBpostgresql-15-hypopg_1.4.2-2.pgdg22.04+1_amd64.deb
postgresql-15-hypopg1.4.2u22.aarch64pgdg72.5 KiBpostgresql-15-hypopg_1.4.2-2.pgdg22.04+1_arm64.deb
postgresql-15-hypopg1.4.2u24.x86_64pgdg57.9 KiBpostgresql-15-hypopg_1.4.2-2.pgdg24.04+1_amd64.deb
postgresql-15-hypopg1.4.2u24.aarch64pgdg58.2 KiBpostgresql-15-hypopg_1.4.2-2.pgdg24.04+1_arm64.deb
PackageVersionOSORGSIZEFile URL
hypopg_141.4.1el8.x86_64pgdg30.6 KiBhypopg_14-1.4.1-1PGDG.rhel8.x86_64.rpm
hypopg_141.4.0el8.x86_64pgdg29.8 KiBhypopg_14-1.4.0-1.rhel8.x86_64.rpm
hypopg_141.3.1el8.x86_64pgdg74.4 KiBhypopg_14-1.3.1-1.rhel8.x86_64.rpm
hypopg_141.4.1el8.aarch64pgdg31.1 KiBhypopg_14-1.4.1-1PGDG.rhel8.aarch64.rpm
hypopg_141.4.0el8.aarch64pgdg30.3 KiBhypopg_14-1.4.0-1.rhel8.aarch64.rpm
hypopg_141.3.1el8.aarch64pgdg73.8 KiBhypopg_14-1.3.1-1.rhel8.aarch64.rpm
hypopg_141.4.1el9.x86_64pgdg29.8 KiBhypopg_14-1.4.1-1PGDG.rhel9.x86_64.rpm
hypopg_141.4.0el9.x86_64pgdg29.1 KiBhypopg_14-1.4.0-1.rhel9.x86_64.rpm
hypopg_141.3.1el9.x86_64pgdg74.5 KiBhypopg_14-1.3.1-1.rhel9.x86_64.rpm
hypopg_141.4.1el9.aarch64pgdg31.2 KiBhypopg_14-1.4.1-1PGDG.rhel9.aarch64.rpm
hypopg_141.4.0el9.aarch64pgdg30.4 KiBhypopg_14-1.4.0-1.rhel9.aarch64.rpm
hypopg_141.3.1el9.aarch64pgdg75.2 KiBhypopg_14-1.3.1-1.rhel9.aarch64.rpm
hypopg_141.4.1el10.x86_64pgdg31.0 KiBhypopg_14-1.4.1-3PGDG.rhel10.x86_64.rpm
hypopg_141.4.1el10.aarch64pgdg32.8 KiBhypopg_14-1.4.1-3PGDG.rhel10.aarch64.rpm
postgresql-14-hypopg1.4.2d12.x86_64pgdg57.8 KiBpostgresql-14-hypopg_1.4.2-2.pgdg12+1_amd64.deb
postgresql-14-hypopg1.4.2d12.aarch64pgdg58.1 KiBpostgresql-14-hypopg_1.4.2-2.pgdg12+1_arm64.deb
postgresql-14-hypopg1.4.2d13.x86_64pgdg58.0 KiBpostgresql-14-hypopg_1.4.2-2.pgdg13+1_amd64.deb
postgresql-14-hypopg1.4.2d13.aarch64pgdg58.6 KiBpostgresql-14-hypopg_1.4.2-2.pgdg13+1_arm64.deb
postgresql-14-hypopg1.4.2u22.x86_64pgdg71.6 KiBpostgresql-14-hypopg_1.4.2-2.pgdg22.04+1_amd64.deb
postgresql-14-hypopg1.4.2u22.aarch64pgdg71.7 KiBpostgresql-14-hypopg_1.4.2-2.pgdg22.04+1_arm64.deb
postgresql-14-hypopg1.4.2u24.x86_64pgdg57.9 KiBpostgresql-14-hypopg_1.4.2-2.pgdg24.04+1_amd64.deb
postgresql-14-hypopg1.4.2u24.aarch64pgdg58.2 KiBpostgresql-14-hypopg_1.4.2-2.pgdg24.04+1_arm64.deb

Source

Install

Make sure PGDG repo available:

pig repo add pgdg -u    # add pgdg repo and update cache

Install this extension with pig:

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

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

Create this extension with:

CREATE EXTENSION hypopg;

Usage

hypopg: Hypothetical indexes for PostgreSQL

HypoPG lets you create hypothetical (virtual) indexes that exist only in the current session and are considered by EXPLAIN (without ANALYZE) for query planning. This enables testing the impact of indexes without the cost of actually creating them.

Functions

FunctionDescription
hypopg_create_index(query text)Create a hypothetical index using CREATE INDEX syntax
hypopg_list_indexes()List all hypothetical indexes in the session
hypopg_drop_index(oid)Drop a specific hypothetical index by OID
hypopg_reset()Drop all hypothetical indexes
hypopg()Return hypothetical indexes in pg_index-like format

Workflow

Create a test table and check the baseline plan:

CREATE TABLE hypo AS SELECT id, 'line ' || id AS val FROM generate_series(1, 10000) id;
ANALYZE hypo;
EXPLAIN SELECT * FROM hypo WHERE id = 1;
-- Seq Scan on hypo (cost=0.00..170.00 rows=1 width=15)

Create a hypothetical index:

SELECT * FROM hypopg_create_index('CREATE INDEX ON hypo (id)');
--  indexrelid |      indexname
-- ------------+----------------------
--       13543 | <13543>btree_hypo_id

Check the plan with the hypothetical index:

EXPLAIN SELECT * FROM hypo WHERE id = 1;
-- Index Scan using <13543>btree_hypo_id on hypo (cost=0.04..8.06 rows=1 width=15)

List and manage hypothetical indexes:

SELECT * FROM hypopg_list_indexes();
SELECT * FROM hypopg_drop_index(13543);
SELECT * FROM hypopg_reset();

Limitations

  • Only EXPLAIN without ANALYZE will consider hypothetical indexes
  • Hypothetical indexes exist only in the current backend session
  • Other concurrent connections are not affected
  • Index names and some CREATE INDEX options are ignored
Last updated on