当前位置:网站首页>mysql 索引
mysql 索引
2022-07-31 01:47:00 【我的天才女友】
索引:一个排序好的数据,索引记录了添加索引的位置与数据表中的数据中每行记录之间的一 一对应的关系。
索引类似于词典中的目录一样。
mysql遍历数据的方式:
顺序遍历:查询会遍历数据库中的数据
索引遍历:找到合适的索引,然后根据索引定位到数据库的对应行的数据,提高数据查询能力
索引优缺点:
优点
- 所有字段都可以添加索引
- 可以为表中一列或者多列添加索引
缺点
- 索引需要占有一定位置,数据更新也需要mysql内部对索引进行内部维护
mysql索引的创建原则
- 数据越小越好,占用的内存越少
- 使用简单的数据类型最好
- 尽量不要在null值创建索引,null值会使索引计算更加难
mysql数据索引在数据中主键或者外键添加索引,表中数据有一定量,此字段多用于数据检索条件、此字段用于分组和排序。
索引的类型
唯一索引(unique)、全文索引(fulltext)、空间索引(spatial)
索引创建
alter table tableName add index indexName(columnName)
边栏推荐
- Overview of prometheus monitoring
- leetcode-1161:最大层内元素和
- Gateway路由的配置方式
- SQLserver查询最近三个月的数据,语句该怎么写sqlserver
- 软件测试缺陷报告---定义,组成,缺陷的生命周期,缺陷跟踪产后处理流程,缺陷跟踪处理流程,缺陷跟踪的目的,缺陷管理工具
- 验证 XML 文档
- Centos 7.9安装PostgreSQL14.4步骤
- What have I experienced when I won the offer of BAT and TMD technical experts?
- I have been working in software testing for 3 years, how did I go from just getting started to automated testing?
- 【微信小程序】一文带你了解数据绑定、事件绑定以及事件传参、数据同步
猜你喜欢
一个无经验的大学毕业生,可以转行做软件测试吗?我的真实案例
Between two orderly array of additive and Topk problem
"Cloud native's master, master and vulgar skills" - 2022 National New College Entrance Examination Volume I Composition
手把手教你配置Jenkins自动化邮件通知
【flask入门系列】Flask-SQLAlchemy的使用
倍增、DFS序
勾股数元组 od js
MySQL (6)
221. 最大正方形
Parameter introduction and selection points of wireless module
随机推荐
Maximum monthly salary of 20K?The average salary is nearly 10,000... What is the experience of working in a Huawei subsidiary?
MySQL installation tutorial (detailed, package teaching package~)
MySQL (6)
聚簇索引和非聚簇索引到底有什么区别
Parameter introduction and selection points of wireless module
蛮力法/邻接表 广度优先 有向带权图 无向带权图
pycharm cannot run after renaming (error: can't open file...No such file or directory)
PDF split/merge
case语句的综合结果,你究竟会了吗?【Verilog高级教程】
华为od 转骰子 js
MySQL的分页你还在使劲的limit?
力扣每日一题-第46天-704. 二分查找
Set the browser scrollbar style
PDF split/merge
android的webview缓存相关知识收集
1782. Count the number of point pairs Double pointer
【genius_platform软件平台开发】第七十四讲:window环境下的静态库和动态库的一些使用方法(VC环境)
MySQL (6)
加密生活,Web3 项目合伙人的一天
第一学年课程期末考试