一、安装dbmind实例
1.添加dbmind主机





2.安装dbmind实例。






3.dbmind纳管GaussDB实例




4.回到被纳管的实例详情页面,发现运维能力增强。

二、使用root登录GaussDB数据库,创建测试库。
sql
su - Ruby
source gauss_env_file
gsql -d postgres -p 8000 -r
create database testdb;
三、构造实验数据。
sql
gsql -d testdb -p 8000 -r
\timing
drop table if exists a;
create table a(id int,error varchar);
insert into a select x,x||'error' from generate_series(1,10000) x;
drop table if exists b;
create table b(id int,error varchar);
insert into b(id) select x from generate_series(1,10000) x;
analyze a;
analyze b;

四、DBMind智能诊断
1.执行以下业务SQL,用id字段关联,用a表中的error列的信覆盖b表中的error列信息,发现执行耗时>25s。
sql
update b set error = (select a.error from a where a.id=b.id) where b.id in(select id from b);

2.登录TPOPS,单击左侧目录"实例管理",进入"实例列表"页面。

3.选择对应的GaussDB实例,单击实例名称进入实例详情页面。
4.单击"诊断优化 > 索引推荐",显示"索引推荐"页面,点击"自定义"选项卡。


5.按照推荐的方式,复制推荐创建索引的DDL,给对应的表添加索引。
sql
testdb=# CREATE INDEX idx_a_id_error ON a(id, error);
CREATE INDEX
Time: 14.635 ms
testdb=#
6.添加索引完成后,重新执行业务SQL,耗时<1s。
sql
testdb=# update b set error = (select a.error from a where a.id=b.id) where b.id in(select id from b);
UPDATE 10000
Time: 84.504 ms
