zoukankan      html  css  js  c++  java
  • Mysql优化(3) 索引优化

     

     

    下面我们为表t2创建一个索引:

    [SQL] 纯文本查看 复制代码
    001
    002
    003
    004
    005
    006
    007
    008
    009
    010
    011
    mysql> create index in_id on t2(id);
    Query OK, 0 rows affected (0.01 sec)
    Records: 0  Duplicates: 0  Warnings: 0
     
    mysql> show index from t2;
    +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
    | 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 in set (0.00 sec)


    并插入1000万行的数据。

    然后再用:

    [SQL] 纯文本查看 复制代码
    001
    explain select * from t2 where id=1;


    或者

    [SQL] 纯文本查看 复制代码
    001
    desc select * from t2 where id=1;


    查询其影响行数。决定其是否需要优化

    http://www.sodu666.com/ZhuShenQi/

    http://tieba.sodu666.com/

     
  • 相关阅读:
    负载均衡——LVS DR模式
    Java之BigDecimal详解
    Spring AOP代理对象创建流程
    spring aop切面不生效
    aspectj-autoproxy Controller未生效解决方案
    jvm参数分类
    dubbo优雅停机
    Dubbo 协议注意项
    dubbo provider
    查找java_home的安装路径
  • 原文地址:https://www.cnblogs.com/onesea/p/15031400.html
Copyright © 2011-2022 走看看