有一 t_mer_info表,其中某列 bms_apply_type 为0、1和空单表查询时速度很快
select * from t_mer_info tmi where tmi.bms_apply_type = '0' and tmi.profit_status ='5'但是当多表联合查询时 如果加上 bms_apply_type的约束条件,查询速度变得极其慢,去掉bms_apply_type 的约束条件 查询速度又很快。select t.mer_no,
t.mer_name,
t.mer_address,
t.mer_contactor,
t.mer_mobile,
t.mer_tel,
t.mer_email,
t.mer_source,
t.profit_status,
t.bms_apply_type,
t.bms_mer_no,
hx.inst_no,
hx.supinstno,
hx.inst_name,
to_char(mp.CREATE_TIME, 'yyyy-MM-dd HH24:mi:ss') as create_time,
pa.ACCOUNT_NO,
pa.ACCOUNT_NAME
from t_mer_info t
inner join account.t_inst hx
on t.org_no = hx.inst_no
inner join t_mer_profitact mp
on t.id = mp.mer_id
inner join T_PROFIT_ACCOUNT pa
on mp.id = pa.PROFITACT_ID
where pa.DEFAULT_ACCOUNT = '1'
and t.bms_apply_type = '0'
and t.profit_status ='5'
请问各位大大 要怎么解决这个问题? 因为业务的需要,bms_apply_type 也必须要加上
select * from t_mer_info tmi where tmi.bms_apply_type = '0' and tmi.profit_status ='5'但是当多表联合查询时 如果加上 bms_apply_type的约束条件,查询速度变得极其慢,去掉bms_apply_type 的约束条件 查询速度又很快。select t.mer_no,
t.mer_name,
t.mer_address,
t.mer_contactor,
t.mer_mobile,
t.mer_tel,
t.mer_email,
t.mer_source,
t.profit_status,
t.bms_apply_type,
t.bms_mer_no,
hx.inst_no,
hx.supinstno,
hx.inst_name,
to_char(mp.CREATE_TIME, 'yyyy-MM-dd HH24:mi:ss') as create_time,
pa.ACCOUNT_NO,
pa.ACCOUNT_NAME
from t_mer_info t
inner join account.t_inst hx
on t.org_no = hx.inst_no
inner join t_mer_profitact mp
on t.id = mp.mer_id
inner join T_PROFIT_ACCOUNT pa
on mp.id = pa.PROFITACT_ID
where pa.DEFAULT_ACCOUNT = '1'
and t.bms_apply_type = '0'
and t.profit_status ='5'
请问各位大大 要怎么解决这个问题? 因为业务的需要,bms_apply_type 也必须要加上
这一列 的数据 有的为空
不影响你建索引但是当我查询 为空的数据时 就有影响吧我查了下 oracle 空值与空值不等的
是的各个环境用的数据库不同修改功能时发现这个sql 效率特表慢 然后想优化下,但测试好多方法 还是不行
看其他大神有没有好的方法