索引使用函数计算

案例

  • 功能:7月份数据统计,t_modified字段上加了索引
  • select count(*) from tradelog where month(t_modified)=7;
  • 由于使用到了函数,虽然用到了索引,但是全索引扫描
  • image.png

    优化

  • select count(*) from tradelog where where t_modified >= ‘2016-7-1’ and t_modified <= ‘2016-7-31’

  • 使用到索引快速定位能力