当前位置:网站首页>MySQL index
MySQL index
2022-06-13 02:44:00 【Cold Snowflakes】
constraint : Ensure data integrity .
Indexes : Quickly locate specific data , Improve query efficiency .
Actually two different concepts , An index is equivalent to establishing a directory in a dictionary .
stay MySQL in , There are usually two ways to access row data of a database table :
1) Sequential access
Sequential access is a full table scan , Traverse line by line from beginning to end , Until the qualified target data is found .
When looking for a small amount of data in tens of millions of data , Using sequential access will traverse all data , It takes a lot of time , Obviously, it will affect the processing performance of the database .
2) Index access
Index access is to directly access the record rows in the table by traversing the index .
The premise is to build an index on the table , After the index is created on the column , When searching data, you can directly find the position of the corresponding record row according to the index on the column , So as to quickly find the data . The index stores a pointer to the specified column data value , Sorts the pointers according to the specified sort order .
for example , On the student list tb_students in , If based on student_id Column indexed , The system establishes a mapping table from the index column to the actual record . When users need to find where student_id = 12022 When , The system starts with student_id The record was found on the index , Then find the data row directly through the mapping table , And return this row of data . Just like the contents in the dictionary .
Because the speed of scanning the index is generally much faster than that of scanning the actual data rows , Therefore, the use of index can greatly improve the efficiency of the database .
Indexes
Indexes are defined on columns .
If the index has already been created on the column as the search criteria ,MySQL No need to scan any record to get the location of the target record quickly .
General index
unique index : The values on this column cannot be repeated , Null value allowed .
primary key : No null values are allowed .
When creating a primary key constraint ,mysql An index will be created automatically by default
To realize that the value of the primary key does not duplicate , You need to retrieve data every time you insert a new record , So in order to improve the retrieval speed , At the same time, create an index on the primary key .
When creating a unique constraint ,mysql A unique index will be created automatically by default
Just like the above , Implement unique constraints through unique indexes
mysql Indexes
mysql Constraints and indexes in
MySQL Index addition and optimization
边栏推荐
- 03 recognize the first view component
- Rough understanding of wechat cloud development
- Opencv 17 face recognition
- Opencv 08 demonstrates the effect of opening and closing operations of erode, dilate and morphological function morphologyex.
- C # illustrated tutorial (Fourth Edition) chapter7-7.2 accessing inherited members
- A wechat app for shopping
- Example 4 linear filtering and built-in filtering
- Sans certificate generation
- Laravel permission export
- How to select fund products? What kind of fund is a good fund?
猜你喜欢

How can intelligent safe power distribution devices reduce the occurrence of electrical fire accidents?

OneNote使用指南(一)

L1 regularization and its sparsity
![[data analysis and visualization] key points of data drawing 11- precautions for radar chart](/img/46/41e4e0fedb3653b119b0e2af836d85.jpg)
[data analysis and visualization] key points of data drawing 11- precautions for radar chart

JS deconstruction assignment
![[data and Analysis Visualization] data operation in D3 tutorial 3-d3](/img/c9/82385b125a8e47d900c320b5f4f3b2.jpg)
[data and Analysis Visualization] data operation in D3 tutorial 3-d3

Laravel 权限导出

02 optimize the default structure of wechat developer tools

Bi modal progressive mask attention for fine graded recognition

02 优化微信开发者工具默认的结构
随机推荐
[reading papers] deep learning face representation by joint identification verification, deep learning applied to optimization problems, deepid2
重定向设置参数-RedirectAttributes
wx. Createselectorquery() gets the usage of DOM nodes in components
[data analysis and visualization] key points of data drawing 5- the problem of error line
Use of OpenCV 12 findcircuits and drawcircuits
[common tools] pyautogui tutorial
L1 regularization and its sparsity
Graph theory, tree based concept
Mp4 playback
02 optimize the default structure of wechat developer tools
專業的數據庫管理軟件:Valentina Studio Pro for Mac
Ijkplayer source code - remuxing
专业的数据库管理软件:Valentina Studio Pro for Mac
Perfect square
Opencv 9 resize size change rotate rotate blur mean (blur)
05 tabbar navigation bar function
Delphi implements adding a column of serial number to the CXGRID list
[life science] DNA extraction of basic biological experiments
Basic principle of bilateral filtering
Traverse the array and delete an element until it is deleted