GBase 8s 使用hint改变执行计划

使用hint改变执行计划

Drop table  if exists t_f_comp;

create table t_f_comp(id1 int,id2 int unique ,name varchar(10) not null );

insert into t_f_comp values (1,1,'a');

insert into t_f_comp values (1,2,'b');

create index t_f_idx on t_f_comp(id1);

create index t_f_idx_name on t_f_comp(name);

update statistics

Dbaccess执行set explain on;后执行以下sql;

select * from  t_f_comp where id1=1 and name='a';

select {+INDEX(t_f_comp,t_f_idx)} * from t_f_comp where id1=1 and name='a';

select {+INDEX(t_f_comp,t_f_idx_name)} * from t_f_comp where id1=1 and name='a';

绑定执行SQL绑定执行计划能力

onconfig EXT_DIRECTIVES=1

export IFX_EXTDIRECTIVES=1

create table t_key(

id int,

c1 varchar(20),

c2 char(20)

);

create index c1_idx on t_key(c1);

insert into t_key values(1,'t_gbase1','ndty');

insert into t_key values(2,'t_gbase2','ndty');
 
查看执行计划,如下sql走索引

select * from t_key where c1 like 't_%';

通过定义绑定执行计划使用顺序扫描

SAVE EXTERNAL DIRECTIVES {+FULL(t_key)} ACTIVE FOR
select * from t_key where c1 like 't_%';
set explain on;
select * from t_key where c2 like 't_%';
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值