当前位置:网站首页>What is the difference between a database unique index and a common index?
What is the difference between a database unique index and a common index?
2022-06-11 02:57:00 【ambition_ forever】
1、 If the business field to update Frequent normalization , Choose a unique index or a normal index ?
If the uniqueness can be guaranteed in the business, try to use the common index instead of the unique index .
2、 For the query, the query of the general index is after the qualified content is found , Continue to the next content query , If the next item does not match, return ; But the only index query is to return the content that meets the conditions directly , On the whole, there is less than one query , But the overall efficiency is not much different .
3、 For the update operation, there is a big gap between the two .
To understand the gap between the two in the update operation, first understand change buffer.
change buffer Used to record update operations , When the data to be updated is not read from the hard disk to the memory , The update operation will be recorded to change buffer in , At the next time select And then read the data before the update into the memory , And then execute change buffer To merge data , This process is called merge.
If it is the update of the unique index , First, it is necessary to determine whether the updated data exists in the database , At this time, there must be a read operation , With the read operation, the hard disk data will be loaded into the memory . In this case, for the update of the unique index change buffer It doesn't make much sense .
If the update of the general index , Will take advantage of change buffer To reduce the update time IO operation , Improve efficiency .
If the read is greater than the write or update operation , There is little difference between choosing a normal index and a unique index . If reading is less than writing , Using a normal index is more efficient , Because it will use change buffer. If you want to query immediately after writing , The efficiency of ordinary indexes is not very good , Because it will involve frequent merge operation , And you need extra space .
边栏推荐
- Win10 安装Office 2016出现错误代码30204-44怎么处理?
- How to state clearly and concisely the product requirements?
- 逃离大城市的年轻人:扛住了房价和压力,没扛住流行病
- DNS Optimization Practice of APP network optimization
- One line of code solves the problem that the time to fetch datetime from MySQL database is less than eight hours
- How to add two factor authentication for WordPress websites
- TCP/IP
- JS memory leak
- When the interviewer opens his mouth, he comes to compose. Is this the case now?
- Prophet
猜你喜欢

Limiting visibility of symbols when linking shared libraries

码农的进阶之路 | 每日趣闻

【新晋开源项目】动态配置化任务编排框架 Gobrs-Async 加入Dromara开源社区

When the interviewer opens his mouth, he comes to compose. Is this the case now?

CPT 102_ LEC 17
![[189. rotation array]](/img/cc/0da616ad9adc9c9d352e54f58dbe41.png)
[189. rotation array]

Write my Ini configuration file error

Arduino Uno接JQ8900-16p语音播报模块

CPT 102_LEC 16

那些笑着离开“北上广”的人,为何最后都哭了?
随机推荐
The two departments jointly issued the nine provisions on fire safety management of off campus training institutions
银行选择电子招标采购的必要性
Sword finger offer II 079 All subsets
Cypress 88359 WL command enable hotspot
error exepected identifier before ‘(‘ token, grpc 枚举类编译错误
20220610 星期五
Uni app - one click access to user information
Google Gmail mailbox marks all unread messages as read at once
Navicat premium 15 tool is automatically deleted by anti-virus protection software solution
What is ttfb
Go 语言的优势和学习路线图
Add SQL formatter to vscode to format SQL
同一个用户的两次请求SessionId竟然不一致-----记录问题
CPT 102_ LEC 17
JS memory leak
Go语言之Go 快速入门篇(一):第一个 Go 程序
Net core Tianma XingKong series - Interface Implementation for dependency injection and mutual conversion of database tables and C entity classes
Wechat template message errCode ": 40165," errmsg ":" invalid web pagepath
TCP/IP
富络经典源码富络经典系统开发原理分享