当前位置:网站首页>MySQL daily experience [02]
MySQL daily experience [02]
2022-06-22 10:47:00 【Anna and her notebook】
️ ️ ️
1、 What is the leftmost prefix principle ? What is the leftmost matching principle ?
2、 What are the data table types
3、 What are the transactions in the database ?
4、 Please briefly describe the types of indexes commonly used ?
5、 Say overlay index ?
1、 What is the leftmost prefix principle ? What is the leftmost matching principle ?
Leftmost prefix principle , It's the top left priority , When creating a multi-column index , According to business needs ,where The most frequently used column in the clause is at the far left .
When we create a composite index , Such as (k1,k2,k3), It's equivalent to creating (k1)、(k1,k2) and (k1,k2,k3) Three indexes , This is the left most matching principle .
Leftmost prefix matching principle and union index Index storage structure and retrieval method It matters .
️
In the composite index tree , The bottom leaf node follows the first column a Columns are arranged incrementally from left to right , however b Column sum c The columns are out of order ,b Column only in a When the column values are the same, the small range increases in order , and c Columns can only be in a,b When the two columns are equal, the order is increased in a small range .
️
Like the query above ,B+ The tree will first compare a Column to determine which direction should be searched next , Left or right . If a Compare the same column b Column . But if the query criteria are not a Column ,B+ The tree doesn't know which node to start from in the first step .
️
It can be said that created idx_abc(a,b,c) Indexes , It's equivalent to creating (a)、(a,b)(a,b,c) Three indexes .
2、 What are the data table types
answer :MyISAM、InnoDB、HEAP、BOB,ARCHIVE,CSV etc. .
MyISAM: mature 、 Stable 、 Easier to manage , Fast read . Some features do not support ( Affairs, etc. ), Table lock .
InnoDB: Support transactions 、 Properties such as foreign keys 、 Data row locking . It takes up a lot of space , Full text indexing, etc. is not supported .
3、 What are the transactions in the database ?
Business (transaction) Is a set of ordered database operations as a unit . If all operations in the group succeed , The transaction is considered successful , Even if only one operation fails , Things don't work . If all operations are complete , Transaction commit , Its modification will affect all other database processes . If an operation fails , The transaction will be rolled back , The influence of the operation of the firm will be cancelled .ACID Four characteristics , Atomicity 、 Isolation, 、 Uniformity 、 persistence .
4、 Please briefly describe the types of indexes commonly used ?
General index : That is to create an index for the database table
unique index : Similar to a normal index , The difference is that :MySQL The value of the database index column must be unique , But you can have an empty value
primary key : It is a special unique index , No null values are allowed . It is common to create a primary key index while building a table
Composite index ( Joint index ): For further extraction MySQL The efficiency of , Consider building a composite index .
That is to combine multiple fields in a database table as a composite index .
5、 Say overlay index ?
Covering an index is not an index structure , Overlay index is a very common Optimization means . Because when using secondary indexes , We can only get the primary key value , It is equivalent to obtaining data and then querying the primary key index according to the primary key to get the data . But imagine the next situation , on top abc_innodb When the composite index query in the table , If I just need abc Field , Does that mean that when we query the leaf node of the composite index, we can directly return , You don't have to go back to the table . This is the case of overlay index .
For example :
Suppose we only need to query the name of the product 、 Price information , What can we do to avoid going back to the table ? We can build a composite index , I.e. commodity code 、 name 、 Price as a composite index . If this data exists in the index , The query will not retrieve the primary key index again , So as to avoid returning to the table .
Query records from the secondary index , It does not need to query through the cluster index ,MySQL Call it the overlay index . The benefits of using overlay indexes are obvious , We don't need to query all the information that contains the entire row of records , So you can reduce a lot of I/O operation .
Usually in InnoDB in , In addition to query some fields can use overlay index to optimize query performance , Statistics also use . for example , SELECT COUNT(*) when , If no secondary index exists , This will
Count rows by querying the aggregate index , If a secondary index happens to exist at this time , The number of rows will be counted by querying the auxiliary index , Reduce I/O operation .
Overlay index :
- In a query , Indexes k already “ covers ” Our query needs , Called overlay index .
- Covering the index can reduce the number of searches in the tree , Significantly improve query performance , Therefore, using overlay index is a common performance optimization method .
边栏推荐
- Target detection / segmentation training using pytorch mask RCNN
- Signal integrity (SI) power integrity (PI) learning notes (XXIV) differential pair and differential impedance (IV)
- 这不会又是一个Go的BUG吧?
- Tiktok announces data storage on Oracle server!
- 从MVC原理开始手敲一个MVC框架,带你体会当大神的乐趣
- 关于 GIN 的路由树
- MySQL使用SQL语句新增字段、删除字段
- The future of Dao: an organization primitive for building Web3
- 喜讯丨敏捷科技入选《2022年中国数字安全百强报告》
- It is said that the price of the iPhone 14 will rise; TikTok US user data is transferred to Oracle, and bytes cannot be accessed; Seatunnel 2.1.2 releases geek headlines
猜你喜欢

软件项目管理 8.3.敏捷项目质量活动

Tiktok announces data storage on Oracle server!

Signal integrity (SI) power integrity (PI) learning notes (XXIV) differential pair and differential impedance (IV)

Laravel 中类似 WordPress 的钩子和过滤器

Zero‐Copy API

普乐蛙VR台风逃生体验VR灾害自救模拟系统VR科普知识设备

IPO Configuration Guide

Vs2022 connecting to SQLSERVER database tutorial

Zero‐Copy API

YOLOv3目标检测
随机推荐
Former amd chip architect roast said that the cancellation of K12 processor project was because amd counseled!
2022-06-09 工作记录--yarn/npm-Error-EPERM: operation not permitted, uv_cwd
In 2022, IPv6 deployment and application will be further promoted. How can we comprehensively realize security upgrading and transformation?
【JMeter】JMeter如何模拟不同的网络速度
Cobalt strike from entry to imprisonment (III)
Using computed columns in laravel
2022陕西省安全员B证操作证考试题库及在线模拟考试
Spark精简面试
超简单的C语言贪吃蛇 不闪屏 双缓冲
力扣 1108. IP 地址无效化
IPO配置指南
[deep learning] great! The new attention makes the model 2-4 times faster!
数据库课程虚拟教研室负责人杜小勇:立足国产数据库重大需求,探索课程体系建设新模式
【毕业季·进击的技术er】青春不散场
Quel est le risque de divulgation d'un certificat de signature de code?
大学生期末考试SQL语句
Introduction to NPM install command
字节三面:到底知不知道什么是Eureka?
Opencv人脸识别之发送QQ邮箱
Backbone! Youxuan software was selected as one of the top 100 digital security companies in China in 2022