查询条件不要使用函数
where条件中的列能不加函数运算就不加函数,因加函数会造成智能索引失效,sql性能降低。
例如:原始sql为:where substr(product_no, 2, 1) in (‘3’, ‘4’, ‘5’, ‘8’),智能索引失效,性能非常低;
改写为: where (product_no like '13%' or product_no like '14%' or product_no like '15%' or product_no like '18%')',智能索引还能用的上(智能索引支持对字符串类型数据前8个字符的索引,再多了就不支持了);