zoukankan      html  css  js  c++  java
  • MySQL索引

    索引
    主键索引、唯一索引、全文索引、普通索引

    索引的作用就是给数据加目录
    可使用Btree与hash
    myisam、innodb使用Btree(存储类型|搜索算法)
    memory存储引擎使用hash与Btree, 默认用hash

    优点: 加快查询的速度
    缺点: 占空间, 增删改数据时, 索引也要跟着变, 数据的维护速度降低了
    降低了增删改的速度
    增大了表文件大小(索引文件甚至可能比数据文件还大)

    建索引的原则:
    为经常要排序、分组的字段建索引
    为经常作为查询条件的字段建索引
    过于集中的值不要索引如给性别"男","女"加索引,意义不大
    删除不再使用或很少使用的索引

    index (id)
    index (name,sex)
    unique index ix1 (id asc)
    fulltext index ix2 (info)
    index ix1 (name(8))
    spatial index (space)

    create index ix1 on emp(id);
    alter table emp add index ix2(name);

    drop index ix1 on emp;

    explain select * from t1 where id =1G

    show full columns from emp;
    show index from emp;
    show create table index1 G

  • 相关阅读:
    Java核心技术-映射
    Java核心技术-具体的集合
    Java核心技术-继承
    Spring MVC 起步
    最小化Spring XML配置
    装配Bean
    Bean和Spirng模块
    Spring入门
    git学习笔记
    CISCN2018-WP
  • 原文地址:https://www.cnblogs.com/wsl222000/p/4950400.html
Copyright © 2011-2022 走看看