在STOCK_CD和TRADE_DT 上面建立索引,sql如下
 select TRADE_DT,SPOT from
 where
STOCK_CD=#{code} and TRADE_DT between #{startDate}
and #{endDate}现在查询至少0.5S 以上,大家有优化的办法吗?MySQL性能优化SQL索引select

解决方案 »

  1.   

    STOCK_CD,TRADE_DT 加联合索引
      

  2.   

    create index xxx on  table1 (STOCK_CD,TRADE_DT)
      

  3.   

    你的索引是怎样建立的,是单一索引?
    show index from xxx在STOCK_CD,TRADE_DT上建立复合索引
      

  4.   

    show index from xxx 贴结果
    只要复合索引 OR 强制使用复合索引
      

  5.   

    show create table xxx 贴结果
    create index xxx on  table1 (STOCK_CD,TRADE_DT) select TRADE_DT,SPOT from xxx force index(xxx)
      where
     STOCK_CD=#{code} and TRADE_DT between #{startDate}
     and #{endDate}