问题描述
select t.* from tbl_part_00 t where 1 = 1 and sm_Id in ('1023352756','1023343286');这句sql怎么优化 问题补充:sm_Id 列上建立有索引还有必要优化吗?看执行计划 走了索引
解决方案
建立sm_Id字段上建立索引后就没必要优化了
解决方案二:
select t.* from tbl_part_00 t where sm_Id = '1023352756' union all select t.* from tbl_part_00 t where sm_Id ='1023343286';
解决方案三:
select t.* from tbl_part_00 t where 1 = 1 and (sm_Id='1023352756' or sm_Id='1023343286');
时间: 2024-10-25 15:09:54