SQL如下:SELECT mv from hb2  where mv = '04b51c24193198af023fe14c22cf53cfc9409c35c5e44e8b'
其中mv建立了索引~hb2大约数据量为100w~执行上面的Sql竟然耗时1秒钟,这实在无法满足需求!

解决方案 »

  1.   

    <img src="http://i.imgur.com/o72zb.jpg" title="Hosted by imgur.com" />
      

  2.   

    上面是explain的结果啊,麻烦大家看看阿~
      

  3.   

    贴出 show index from hb2 ;以文本方式贴出,不要贴图。mysql> show index from wsz2;
    +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
    | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
    +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
    | wsz2  |          0 | PRIMARY  |            1 | id          | A         |           5 |     NULL | NULL   |      | BTREE      |         |               |
    | wsz2  |          1 | name     |            1 | name        | A         |           5 |     NULL | NULL   |      | BTREE      |         |               |
    | wsz2  |          1 | name     |            2 | time        | A         |           5 |     NULL | NULL   |      | BTREE      |         |               |
    +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
    3 rows in set (0.55 sec)mysql>
      

  4.   

    没用到索引啊
    show create table tbname看看你有索引吗
      

  5.   

    确定HB2中MV上有索引?检查一下 
    show index from HB2
    贴结果
      

  6.   

    MYSQL的目标不就是要做到尽快查询吗?
    你的where 用了什么过滤的?非索引字段?
      

  7.   

    Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
    都是空的好像是没索引可是我明明在程序里建了阿
    String i1 = "CREATE INDEX index_mv ON " + tName + " (mv)";
      

  8.   

    在MYSQL中再建立一下
    显示i1中的内容出来看看