跳转到主要内容

index_advisor

查询索引建议器

index_advisor · 查询索引建议器

概览

ID扩展软件包版本类别许可证编程语言
2800index_advisorindex_advisor0.2.1FEATPostgreSQLSQL
属性可执行文件动态库需要预加载需要建扩展可迁移可信
----d-r否否否是是否
Package and SQL version 0.2.1; requires HypoPG; planner estimates only.

软件包

类型仓库版本兼容的 PostgreSQL 大版本包名模式依赖
EXTPIGSTY0.2.119 18 17 16 15index_advisorhypopg
RPMPIGSTY0.2.119 18 17 16 15index_advisor_$vhypopg_$v
DEBPIGSTY0.2.119 18 17 16 15postgresql-$v-index-advisorpostgresql-$v-hypopg
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
el8.aarch64N/APIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
el9.x86_64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
el9.aarch64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
el10.x86_64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
el10.aarch64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
d12.x86_64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
d12.aarch64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
d13.x86_64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
d13.aarch64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
u22.x86_64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
u22.aarch64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
u24.x86_64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
u24.aarch64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
u26.x86_64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
u26.aarch64PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1PIGSTY 0.2.1
软件包版本平台仓库大小下载
index_advisor_190.2.1el9.x86_64pigsty10.2 KiBindex_advisor_19-0.2.1-1PGSTY.el9.noarch.rpm
index_advisor_190.2.1el9.aarch64pigsty10.2 KiBindex_advisor_19-0.2.1-1PGSTY.el9.noarch.rpm
index_advisor_190.2.1el10.x86_64pigsty10.4 KiBindex_advisor_19-0.2.1-1PGSTY.el10.noarch.rpm
index_advisor_190.2.1el10.aarch64pigsty10.4 KiBindex_advisor_19-0.2.1-1PGSTY.el10.noarch.rpm
postgresql-19-index-advisor0.2.1d12.x86_64pigsty6.1 KiBpostgresql-19-index-advisor_0.2.1-1PGSTY~bookworm_all.deb
postgresql-19-index-advisor0.2.1d12.aarch64pigsty6.1 KiBpostgresql-19-index-advisor_0.2.1-1PGSTY~bookworm_all.deb
postgresql-19-index-advisor0.2.1d13.x86_64pigsty6.1 KiBpostgresql-19-index-advisor_0.2.1-1PGSTY~trixie_all.deb
postgresql-19-index-advisor0.2.1d13.aarch64pigsty6.1 KiBpostgresql-19-index-advisor_0.2.1-1PGSTY~trixie_all.deb
postgresql-19-index-advisor0.2.1u22.x86_64pigsty6.3 KiBpostgresql-19-index-advisor_0.2.1-1PGSTY~jammy_all.deb
postgresql-19-index-advisor0.2.1u22.aarch64pigsty6.3 KiBpostgresql-19-index-advisor_0.2.1-1PGSTY~jammy_all.deb
postgresql-19-index-advisor0.2.1u24.x86_64pigsty6.3 KiBpostgresql-19-index-advisor_0.2.1-1PGSTY~noble_all.deb
postgresql-19-index-advisor0.2.1u24.aarch64pigsty6.3 KiBpostgresql-19-index-advisor_0.2.1-1PGSTY~noble_all.deb
postgresql-19-index-advisor0.2.1u26.x86_64pigsty6.3 KiBpostgresql-19-index-advisor_0.2.1-1PGSTY~resolute_all.deb
postgresql-19-index-advisor0.2.1u26.aarch64pigsty6.3 KiBpostgresql-19-index-advisor_0.2.1-1PGSTY~resolute_all.deb
软件包版本平台仓库大小下载
index_advisor_180.2.1el8.x86_64pigsty10.4 KiBindex_advisor_18-0.2.1-1PGSTY.el8.noarch.rpm
index_advisor_180.2.1el8.aarch64pigsty10.4 KiBindex_advisor_18-0.2.1-1PGSTY.el8.noarch.rpm
index_advisor_180.2.1el9.x86_64pigsty10.2 KiBindex_advisor_18-0.2.1-1PGSTY.el9.noarch.rpm
index_advisor_180.2.1el9.aarch64pigsty10.2 KiBindex_advisor_18-0.2.1-1PGSTY.el9.noarch.rpm
index_advisor_180.2.1el10.x86_64pigsty10.4 KiBindex_advisor_18-0.2.1-1PGSTY.el10.noarch.rpm
index_advisor_180.2.1el10.aarch64pigsty10.4 KiBindex_advisor_18-0.2.1-1PGSTY.el10.noarch.rpm
postgresql-18-index-advisor0.2.1d12.x86_64pigsty6.1 KiBpostgresql-18-index-advisor_0.2.1-1PGSTY~bookworm_all.deb
postgresql-18-index-advisor0.2.1d12.aarch64pigsty6.1 KiBpostgresql-18-index-advisor_0.2.1-1PGSTY~bookworm_all.deb
postgresql-18-index-advisor0.2.1d13.x86_64pigsty6.1 KiBpostgresql-18-index-advisor_0.2.1-1PGSTY~trixie_all.deb
postgresql-18-index-advisor0.2.1d13.aarch64pigsty6.1 KiBpostgresql-18-index-advisor_0.2.1-1PGSTY~trixie_all.deb
postgresql-18-index-advisor0.2.1u22.x86_64pigsty6.3 KiBpostgresql-18-index-advisor_0.2.1-1PGSTY~jammy_all.deb
postgresql-18-index-advisor0.2.1u22.aarch64pigsty6.3 KiBpostgresql-18-index-advisor_0.2.1-1PGSTY~jammy_all.deb
postgresql-18-index-advisor0.2.1u24.x86_64pigsty6.2 KiBpostgresql-18-index-advisor_0.2.1-1PGSTY~noble_all.deb
postgresql-18-index-advisor0.2.1u24.aarch64pigsty6.2 KiBpostgresql-18-index-advisor_0.2.1-1PGSTY~noble_all.deb
postgresql-18-index-advisor0.2.1u26.x86_64pigsty6.3 KiBpostgresql-18-index-advisor_0.2.1-1PGSTY~resolute_all.deb
postgresql-18-index-advisor0.2.1u26.aarch64pigsty6.3 KiBpostgresql-18-index-advisor_0.2.1-1PGSTY~resolute_all.deb
软件包版本平台仓库大小下载
index_advisor_170.2.1el8.x86_64pigsty10.4 KiBindex_advisor_17-0.2.1-1PGSTY.el8.noarch.rpm
index_advisor_170.2.1el8.aarch64pigsty10.4 KiBindex_advisor_17-0.2.1-1PGSTY.el8.noarch.rpm
index_advisor_170.2.1el9.x86_64pigsty10.2 KiBindex_advisor_17-0.2.1-1PGSTY.el9.noarch.rpm
index_advisor_170.2.1el9.aarch64pigsty10.2 KiBindex_advisor_17-0.2.1-1PGSTY.el9.noarch.rpm
index_advisor_170.2.1el10.x86_64pigsty10.4 KiBindex_advisor_17-0.2.1-1PGSTY.el10.noarch.rpm
index_advisor_170.2.1el10.aarch64pigsty10.4 KiBindex_advisor_17-0.2.1-1PGSTY.el10.noarch.rpm
postgresql-17-index-advisor0.2.1d12.x86_64pigsty6.1 KiBpostgresql-17-index-advisor_0.2.1-1PGSTY~bookworm_all.deb
postgresql-17-index-advisor0.2.1d12.aarch64pigsty6.1 KiBpostgresql-17-index-advisor_0.2.1-1PGSTY~bookworm_all.deb
postgresql-17-index-advisor0.2.1d13.x86_64pigsty6.1 KiBpostgresql-17-index-advisor_0.2.1-1PGSTY~trixie_all.deb
postgresql-17-index-advisor0.2.1d13.aarch64pigsty6.1 KiBpostgresql-17-index-advisor_0.2.1-1PGSTY~trixie_all.deb
postgresql-17-index-advisor0.2.1u22.x86_64pigsty6.3 KiBpostgresql-17-index-advisor_0.2.1-1PGSTY~jammy_all.deb
postgresql-17-index-advisor0.2.1u22.aarch64pigsty6.3 KiBpostgresql-17-index-advisor_0.2.1-1PGSTY~jammy_all.deb
postgresql-17-index-advisor0.2.1u24.x86_64pigsty6.2 KiBpostgresql-17-index-advisor_0.2.1-1PGSTY~noble_all.deb
postgresql-17-index-advisor0.2.1u24.aarch64pigsty6.2 KiBpostgresql-17-index-advisor_0.2.1-1PGSTY~noble_all.deb
postgresql-17-index-advisor0.2.1u26.x86_64pigsty6.3 KiBpostgresql-17-index-advisor_0.2.1-1PGSTY~resolute_all.deb
postgresql-17-index-advisor0.2.1u26.aarch64pigsty6.3 KiBpostgresql-17-index-advisor_0.2.1-1PGSTY~resolute_all.deb
软件包版本平台仓库大小下载
index_advisor_160.2.1el8.x86_64pigsty10.4 KiBindex_advisor_16-0.2.1-1PGSTY.el8.noarch.rpm
index_advisor_160.2.1el8.aarch64pigsty10.4 KiBindex_advisor_16-0.2.1-1PGSTY.el8.noarch.rpm
index_advisor_160.2.1el9.x86_64pigsty10.2 KiBindex_advisor_16-0.2.1-1PGSTY.el9.noarch.rpm
index_advisor_160.2.1el9.aarch64pigsty10.2 KiBindex_advisor_16-0.2.1-1PGSTY.el9.noarch.rpm
index_advisor_160.2.1el10.x86_64pigsty10.4 KiBindex_advisor_16-0.2.1-1PGSTY.el10.noarch.rpm
index_advisor_160.2.1el10.aarch64pigsty10.4 KiBindex_advisor_16-0.2.1-1PGSTY.el10.noarch.rpm
postgresql-16-index-advisor0.2.1d12.x86_64pigsty6.1 KiBpostgresql-16-index-advisor_0.2.1-1PGSTY~bookworm_all.deb
postgresql-16-index-advisor0.2.1d12.aarch64pigsty6.1 KiBpostgresql-16-index-advisor_0.2.1-1PGSTY~bookworm_all.deb
postgresql-16-index-advisor0.2.1d13.x86_64pigsty6.1 KiBpostgresql-16-index-advisor_0.2.1-1PGSTY~trixie_all.deb
postgresql-16-index-advisor0.2.1d13.aarch64pigsty6.1 KiBpostgresql-16-index-advisor_0.2.1-1PGSTY~trixie_all.deb
postgresql-16-index-advisor0.2.1u22.x86_64pigsty6.2 KiBpostgresql-16-index-advisor_0.2.1-1PGSTY~jammy_all.deb
postgresql-16-index-advisor0.2.1u22.aarch64pigsty6.2 KiBpostgresql-16-index-advisor_0.2.1-1PGSTY~jammy_all.deb
postgresql-16-index-advisor0.2.1u24.x86_64pigsty6.2 KiBpostgresql-16-index-advisor_0.2.1-1PGSTY~noble_all.deb
postgresql-16-index-advisor0.2.1u24.aarch64pigsty6.2 KiBpostgresql-16-index-advisor_0.2.1-1PGSTY~noble_all.deb
postgresql-16-index-advisor0.2.1u26.x86_64pigsty6.3 KiBpostgresql-16-index-advisor_0.2.1-1PGSTY~resolute_all.deb
postgresql-16-index-advisor0.2.1u26.aarch64pigsty6.3 KiBpostgresql-16-index-advisor_0.2.1-1PGSTY~resolute_all.deb
软件包版本平台仓库大小下载
index_advisor_150.2.1el8.x86_64pigsty10.4 KiBindex_advisor_15-0.2.1-1PGSTY.el8.noarch.rpm
index_advisor_150.2.1el8.aarch64pigsty10.4 KiBindex_advisor_15-0.2.1-1PGSTY.el8.noarch.rpm
index_advisor_150.2.1el9.x86_64pigsty10.2 KiBindex_advisor_15-0.2.1-1PGSTY.el9.noarch.rpm
index_advisor_150.2.1el9.aarch64pigsty10.2 KiBindex_advisor_15-0.2.1-1PGSTY.el9.noarch.rpm
index_advisor_150.2.1el10.x86_64pigsty10.4 KiBindex_advisor_15-0.2.1-1PGSTY.el10.noarch.rpm
index_advisor_150.2.1el10.aarch64pigsty10.4 KiBindex_advisor_15-0.2.1-1PGSTY.el10.noarch.rpm
postgresql-15-index-advisor0.2.1d12.x86_64pigsty6.1 KiBpostgresql-15-index-advisor_0.2.1-1PGSTY~bookworm_all.deb
postgresql-15-index-advisor0.2.1d12.aarch64pigsty6.1 KiBpostgresql-15-index-advisor_0.2.1-1PGSTY~bookworm_all.deb
postgresql-15-index-advisor0.2.1d13.x86_64pigsty6.1 KiBpostgresql-15-index-advisor_0.2.1-1PGSTY~trixie_all.deb
postgresql-15-index-advisor0.2.1d13.aarch64pigsty6.1 KiBpostgresql-15-index-advisor_0.2.1-1PGSTY~trixie_all.deb
postgresql-15-index-advisor0.2.1u22.x86_64pigsty6.3 KiBpostgresql-15-index-advisor_0.2.1-1PGSTY~jammy_all.deb
postgresql-15-index-advisor0.2.1u22.aarch64pigsty6.3 KiBpostgresql-15-index-advisor_0.2.1-1PGSTY~jammy_all.deb
postgresql-15-index-advisor0.2.1u24.x86_64pigsty6.3 KiBpostgresql-15-index-advisor_0.2.1-1PGSTY~noble_all.deb
postgresql-15-index-advisor0.2.1u24.aarch64pigsty6.3 KiBpostgresql-15-index-advisor_0.2.1-1PGSTY~noble_all.deb
postgresql-15-index-advisor0.2.1u26.x86_64pigsty6.3 KiBpostgresql-15-index-advisor_0.2.1-1PGSTY~resolute_all.deb
postgresql-15-index-advisor0.2.1u26.aarch64pigsty6.3 KiBpostgresql-15-index-advisor_0.2.1-1PGSTY~resolute_all.deb

源码

pig build pkg index_advisor;		# build rpm/deb

安装

启用 PGDG 和 PIGSTY 仓库并更新缓存。

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

使用 pig 安装扩展。

pig install index_advisor;		# install by package name

pig install index_advisor -v 19;   # install for PG 19
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

在数据库中创建扩展。

CREATE EXTENSION index_advisor CASCADE; -- requires hypopg

用法

来源:

index_advisor 0.2.1 使用 HypoPG 比较假想索引建立前后的规划器成本。它返回建议,不保证实际执行时间,也不会创建建议的物理索引。

基本流程

先以所需权限安装依赖 hypopg。该 SQL 扩展不需要预加载或重启。

CREATE EXTENSION hypopg;
CREATE EXTENSION index_advisor;
CREATE TABLE book (id bigint PRIMARY KEY, title text NOT NULL);
SELECT * FROM index_advisor('SELECT id FROM book WHERE title = $1');

index_advisor(query text) 接受带参数的查询,返回建立索引前后的启动成本、总成本、index_statements 和 errors。创建索引前应检查建议 DDL 和实际负载。视图及物化视图支持取决于顾问能否解析到底层表。

0.2.1 修复与边界

0.2.1 修复 HypoPG 安装在其他模式时的函数限定、注释移除的非贪婪匹配,以及仅清理顾问自身预备语句的行为。安装新 SQL 文件后,执行 ALTER EXTENSION index_advisor UPDATE TO '0.2.1' 更新已有数据库。

应以明确的表访问权限和有代表性的统计信息进行分析。规划成本不能覆盖全部运维代价;额外索引消耗磁盘并增加写入开销,上线前应针对实际查询形式验证。

表格阅读器