hypopg
hypopg
hypopg : Hypothetical indexes for PostgreSQL
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 2790 | hypopg
|
hypopg
|
1.4.2 |
FEAT
|
PostgreSQL
|
C
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--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
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| 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 / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
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
|
Source
Install
Make sure PGDG repo available:
pig repo add pgdg -u # add pgdg repo and update cacheInstall 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 14Create this extension with:
CREATE EXTENSION hypopg;Usage
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
| Function | Description |
|---|---|
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_idCheck 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
EXPLAINwithoutANALYZEwill 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