下面我们为表t2创建一个索引:
[SQL] 纯文本查看 复制代码
001002003004005006007008009010011
   | mysql> createindexin_id ont2(id);Query OK, 0 rowsaffected (0.01 sec)Records: 0  Duplicates: 0  Warnings: 0  
  mysql> show indexfromt2;+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+| Table| Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null| Index_type | Comment |+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+| t2    |          1 | in_id    |            1 | id          | A         |        NULL|     NULL| NULL| YES  | BTREE      |         |+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+1 row inset(0.00 sec)  | 
并插入1000万行的数据。
然后再用:
[SQL] 纯文本查看 复制代码
001
   | explain select* fromt2 whereid=1;  | 
或者
[SQL] 纯文本查看 复制代码
001
   | descselect* fromt2 whereid=1;  | 
查询其影响行数。决定其是否需要优化
http://www.sodu666.com/ZhuShenQi/
http://tieba.sodu666.com/
 
 
 
    
    
    
            
下面我们为表t2创建一个索引:
[SQL] 纯文本查看 复制代码
001002003004005006007008009010011
   | mysql> createindexin_id ont2(id);Query OK, 0 rowsaffected (0.01 sec)Records: 0  Duplicates: 0  Warnings: 0  
  mysql> show indexfromt2;+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+| Table| Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null| Index_type | Comment |+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+| t2    |          1 | in_id    |            1 | id          | A         |        NULL|     NULL| NULL| YES  | BTREE      |         |+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+1 row inset(0.00 sec)  | 
并插入1000万行的数据。
然后再用:
[SQL] 纯文本查看 复制代码
001
   | explain select* fromt2 whereid=1;  | 
或者
[SQL] 纯文本查看 复制代码
001
   | descselect* fromt2 whereid=1;  | 
查询其影响行数。决定其是否需要优化
http://www.sodu666.com/ZhuShenQi/
http://tieba.sodu666.com/