当前位置:网站首页>简单描述 MySQL 中,索引,主键,唯一索引,联合索引 的区别,对数据库的性能有什么影响(从读写两方面)
简单描述 MySQL 中,索引,主键,唯一索引,联合索引 的区别,对数据库的性能有什么影响(从读写两方面)
2022-07-06 06:41:00 【辰风沐阳】
1. 前言
简单描述 MySQL 中,索引,主键,唯一索引,联合索引 的区别,对数据库的性能有什么影响(从读写两方面)
这是一道非常经典的 MySQL 索引面试题,意在看面试者是否了解索引的几种类型以及索引的优点和存在的弊端
2. 几种索引类型的区别
索引是帮助数据库高效获取数据的一种数据结构,索引文件中记录着对数据表数据的引用指针
主键是一种特殊的唯一索引,在一张表中只能有一个主键索引,主键索引用于唯一标识一条记录
唯一索引用于确保某一列只包含各不相同的值,也就是说,唯一索引可以保证数据记录的唯一性
联合索引是指通过多个列建立的索引,比如有: 联合主键索引,联合唯一索引
3. 索引读写方面对数据库性能的影响
读: 索引可以极大的提高数据查询速度,建立索引后会生成索引文件,所以本质上索引是以空间换时间。
写: 索引会降低插入,删除,更新的速度,是因为当数据发生改变后,会重新建立索引,那么就会重新构建索引文件,导致增删改操作变慢
边栏推荐
- My daily learning records / learning methods
- Simple query cost estimation
- AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models.common‘ from ‘/home/yolov5/models/comm
- Office doc add in - Online CS
- pymongo获取一列数据
- Traffic encryption of red blue confrontation (OpenSSL encrypted transmission, MSF traffic encryption, CS modifying profile for traffic encryption)
- Apache dolphin scheduler source code analysis (super detailed)
- (practice C language every day) reverse linked list II
- Phishing & filename inversion & Office remote template
- Lecture 8: 1602 LCD (Guo Tianxiang)
猜你喜欢
中英对照:You can do this. Best of luck祝你好运
It is necessary to understand these characteristics in translating subtitles of film and television dramas
[unity] how to export FBX in untiy
After working for 10 years, I changed to a programmer. Now I'm 35 + years old and I'm not anxious
Suspended else
今日夏至 Today‘s summer solstice
AI on the cloud makes earth science research easier
Modify the list page on the basis of jeecg boot code generation (combined with customized components)
Today's summer solstice
论文摘要翻译,多语言纯人工翻译
随机推荐
Market segmentation of supermarket customers based on purchase behavior data (RFM model)
论文摘要翻译,多语言纯人工翻译
What are the commonly used English words and sentences about COVID-19?
Number of query fields
Basic commands of MySQL
MySQL5.72. MSI installation failed
自动化测试环境配置
[ 英語 ] 語法重塑 之 動詞分類 —— 英語兔學習筆記(2)
机器人类专业不同层次院校课程差异性简述-ROS1/ROS2-
雲上有AI,讓地球科學研究更省力
Day 246/300 ssh连接提示“REMOTE HOST IDENTIFICATION HAS CHANGED! ”
Grouping convolution and DW convolution, residuals and inverted residuals, bottleneck and linearbottleneck
Explain in detail the functions and underlying implementation logic of the groups sets statement in SQL
What is the difference between int (1) and int (10)? Senior developers can't tell!
How to do a good job in financial literature translation?
SSO process analysis
成功解决AttributeError: Can only use .cat accessor with a ‘category‘ dtype
利用快捷方式-LNK-上线CS
Machine learning plant leaf recognition
26岁从财务转行软件测试,4年沉淀我已经是25k的测开工程师...