当前位置:网站首页>mysql 索引
mysql 索引
2022-07-31 01:47:00 【我的天才女友】
索引:一个排序好的数据,索引记录了添加索引的位置与数据表中的数据中每行记录之间的一 一对应的关系。
索引类似于词典中的目录一样。
mysql遍历数据的方式:
顺序遍历:查询会遍历数据库中的数据
索引遍历:找到合适的索引,然后根据索引定位到数据库的对应行的数据,提高数据查询能力
索引优缺点:
优点
- 所有字段都可以添加索引
- 可以为表中一列或者多列添加索引
缺点
- 索引需要占有一定位置,数据更新也需要mysql内部对索引进行内部维护
mysql索引的创建原则
- 数据越小越好,占用的内存越少
- 使用简单的数据类型最好
- 尽量不要在null值创建索引,null值会使索引计算更加难
mysql数据索引在数据中主键或者外键添加索引,表中数据有一定量,此字段多用于数据检索条件、此字段用于分组和排序。
索引的类型
唯一索引(unique)、全文索引(fulltext)、空间索引(spatial)
索引创建
alter table tableName add index indexName(columnName)
边栏推荐
- Crypto Life, a day in the life of a Web3 project partner
- 来自一位女测试工程师的内心独白...
- 16、注册中心-consul
- Are you still working hard on the limit of MySQL paging?
- Interprocess communication study notes
- cudaMemcpy学习笔记
- "Real" emotions dictionary based on the text sentiment analysis and LDA theme analysis
- MySQL stored procedure
- coldfusion文件读取漏洞(CVE-2010-2861)
- MySQL installation tutorial (detailed, package teaching package~)
猜你喜欢
leetcode-952:按公因数计算最大组件大小
《云原生的本手、妙手和俗手》——2022全国新高考I卷作文
Bert usage and word prediction based on Keras_bert model
tkinter模块高级操作(二)—— 界面切换效果、立体阴影字效果及gif动图的实现
"Cloud native's master, master and vulgar skills" - 2022 National New College Entrance Examination Volume I Composition
软件测试基础接口测试-入门Jmeter,你要注意这些事
Path and the largest
"Real" emotions dictionary based on the text sentiment analysis and LDA theme analysis
[Map and Set] LeetCode & Niu Ke exercise
12 pictures take you to fully understand service current limit, circuit breaker, downgrade, and avalanche
随机推荐
Programmer's debriefing report/summary
leetcode-952: Calculate max component size by common factor
TiDB 在长银五八消费金融核心系统适配经验分享
tkinter模块高级操作(二)—— 界面切换效果、立体阴影字效果及gif动图的实现
力扣每日一题-第46天-704. 二分查找
leetcode-399: division evaluation
Arbitrum 专访 | L2 Summer, 脱颖而出的 Arbitrum 为开发者带来了什么?
prometheus 监控概述
软件测试工作3年了,谈谈我是如何从刚入门进阶到自动化测试的?
来自一位女测试工程师的内心独白...
ROS Action通信
Inner monologue from a female test engineer...
MySql的初识感悟,以及sql语句中的DDL和DML和DQL的基本语法
The difference between 4G communication module CAT1 and CAT4
汉诺塔问题
Simple confession page
After reading "MySQL Database Advanced Practice" (SQL Xiao Xuzhu)
太阳能板最大面积 od js
手把手教你配置Jenkins自动化邮件通知
Arbitrum Interview | L2 Summer, what does the standout Arbitrum bring to developers?