【我和openGauss的故事】openGauss价值特性 (二)

文章详细介绍了openGauss数据库中的Index-Advisor功能,包括单查询索引推荐、虚拟索引和负载级别索引推荐。通过示例展示了如何使用这些工具来优化查询性能,比如利用gs_index_advise()函数分析查询语句并建议创建索引,以及使用虚拟索引(hypopg_create_index)预估索引效果,最后提到了针对工作负载的索引推荐脚本。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

【我和openGauss的故事】openGauss价值特性 (二)

索引推荐(Index-Advisor)

Index-Advisor共包含三个子功能,单查询索引推荐,虚拟索引和负载级别索引推荐。

单查询索引推荐

功能支持用户在数据库中直接进行操作,本功能基于查询语句的语义信息和数据库的统计信息,对用户输入的单条查询语句生成推荐的索引。本功能涉及的函数接口如下。

gs_index_advise() 功能:只针对单条的SQL语句

环境如下:

openGauss=# select count(*) from employee;
count
---------
1000000
(1 row)

-----------------------------------------------------------------------------

openGauss=# \d employee;
Table "public.employee"
Column | Type | Modifiers
---------+---------+-----------
empid | integer | not null
empname | text | not null
deptid | integer | not null
salary | integer | not null
Indexes:
"idx_empdepid" btree (deptid) TABLESPACE pg_default

openGauss=# ANALYZE employee;
ANALYZE

下面开始测试:

openGauss=# SELECT * FROM gs_index_advise('select * from employee where empid<1');
schema | table | column | indextype
------
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值