当前位置:网站首页>MySQL summary
MySQL summary
2022-06-30 06:01:00 【Flower master】
1、mysql What are the indexes
primary key He has to be primary key Each table can have only one index
A normal index is also called a secondary index , Accelerated search
unique index :
primary key :primary key : Accelerated search + constraint ( Not empty and unique )
unique index :unique: Accelerated search + constraint ( only )
Joint index :
Follow the prefix principle
Full-text index :
When searching for a long article , The best effect .
2、 Clustered index and non clustered index
The difference between a clustered index and a nonclustered index is : Whether the leaf node stores a whole row of records
InnoDB The primary key uses a clustered index ,MyISAM Whether it's a primary key index , Whether the secondary index uses non clustered index .
3、innodb and myisam The difference between
innodb Support things ,myisam Do not support things
Cluster index , Nonclustered index
Row lock , Table locks
Full text indexing is not supported , Full-text index
InnoDB Support foreign keys , and MyISAM I won't support it
4、innodb Engine 4 Big characteristic
Insert buffer (insert buffer), The two time to write (double write), adaptive hash index (ahi), read-ahead (read ahead)
5、MySQL The principle and process of replication
Mainly depends on
6、 Characteristics of things acid
Atomicity (Atomicity, Or indivisibility )
Uniformity (Consistency)
Isolation, (Isolation)
persistence (Durability)
InnoDB The storage engine also provides two types of transaction logs :redo log( Redo log ) and undo log( Rollback log ). among redo log Used to ensure transaction persistence ;undo log Is the basis for atomicity and isolation of transactions .
7、 redo log And binlog
We know , stay MySQL There is still binlog( Binary log ) Write operations can also be recorded and used for data recovery , But they are fundamentally different :
(1) The effect is different :redo log Is used for crash recovery Of , Guarantee MySQL Downtime also does not affect persistence ;binlog Is used for point-in-time recovery Of , Ensure that the server can recover data based on time points , Besides binlog Also used for master-slave replication .
(2) Different levels :redo log yes InnoDB Storage engine implementation , and binlog yes MySQL The server layer of ( You can refer to the front of the article MySQL Introduction to logical architecture ) Realized , Support at the same time InnoDB And other storage engines .
(3) The content is different :redo log It's a physical log , Content is disk-based Page;binlog The content of is binary , according to binlog_format Parameter difference , It may be based on sql sentence 、 Based on the data itself or a mixture of the two .
(4) Different write times :binlog Write at transaction commit time ;redo log The write time is relatively multivariate :
As mentioned earlier : Called when a transaction commits fsync Yes redo log To brush plate ; This is the default policy , modify innodb_flush_log_at_trx_commit Parameters can change the policy , But the durability of the transaction will not be guaranteed .
Except when the transaction commits , There are other brush times : Such as master thread Swipe the disk once a second redo log etc. , The advantage is that it doesn't have to wait commit When the brush set ,commit The speed has been greatly accelerated .
8、 The transaction isolation
1、 Read uncommitted ( Dirty reading ) Uncommitted data read
2、 Read submitted ( It can't be read repeatedly ) What I read is the latest log,
3、 Repeatable ( Fantasy reading ) -- resolvent . The difference between unrepeatable reading and phantom reading can be popularly understood as : The first is that the data changed , The latter is that the number of rows of data has changed .( adopt
4、RR To solve the dirty read 、 It can't be read repeatedly 、 Illusory reading and so on , It uses MVCC:MVCC Full name Multi-Version Concurrency Control, Multiple versions of the concurrency control protocol .
9、mvcc
The solution is dirty reading 、 It can't be read repeatedly 、 The problem of unreal reading
gap and next_lock
10、B+ Trees
The underlying leaf node is a two-way linked list
11、mysql Optimize
configuration :
1、buffer_pool Try to 75%-80%
2、 Size the number of connections
3、 modify wait_timeout The default time for is from 8 Hours changed to 1 Hours
4、 More open cache than write , Otherwise, it is recommended to close
Design optimization :
Create table time , Available fields can be used tinyint Do not use int.
The more indexes you create, the better , When you consider creating an index, you also need to create .
In terms of use
Return only the required fields .
Do not use null, Does not occupy a space , It is no longer in the index range .
Less use like
A very referential address :
边栏推荐
- Strlen and sizeof, array length and string length, don't be silly
- hashlips_ art_ Engine-1.0.6 usage
- 雲服務器部署 Web 項目
- Summary of redis learning notes (I)
- Gestion des utilisateurs de la base de données MySQL
- Solidity - Security - reentrancy attack
- UE4_ Editor UMG close window cannot destroy UMG immediately
- Implementation of property management system with ssm+ wechat applet
- Shenzhou ares tx6 boot logo modification tutorial
- 领导:谁再用 Redis 过期监听实现关闭订单,立马滚蛋!
猜你喜欢

MySQL storage system

ECS deployment web project

MySQL存储系统

How to automatically renew a token after it expires?

Intelligent question - horse racing question

电脑查看WiFi使用密码

Feisheng: Based on the Chinese word breaker ik-2 ways to build custom hot word separators Showcase & pit arrangement Showtime

MySQL advanced (Advanced SQL statement)
![[chestnut sugar GIS] global mapper - how to assign the elevation value of the grid to the point](/img/bb/ea0e78065ba54ff253995faeeb6901.png)
[chestnut sugar GIS] global mapper - how to assign the elevation value of the grid to the point

Inno setup the simplest user-defined interface effect
随机推荐
[chestnut sugar GIS] global mapper - how to assign the elevation value of the grid to the point
超简单 STM32 RTC闹钟 时钟配置
Mysql database user management
Solidity - Security - reentrancy attack
Prototype and prototype chain in JS
Voting vault: a new primitive for defi and Governance
动态规划--怪盗基德的滑翔翼
[ansible series] fundamentals -01
Leetcode56. consolidation interval
Luogup2756 pilot pairing scheme problem (maximum flow)
Leetcode search insert location
CompletableFuture从了解到精通,你想知道的这里都有
股票在网上开户安全吗?在网上能不能开户炒股呢?
Golang's handwritten Web Framework
[GPU] basic operation
[ansible series] fundamentals 02 module debug
Zibll子比主题V6.4.1wordpress 开心版源码下载_破解原版/直接使用/无需教程
Dao -- a beautiful new world?
MySQL transaction
Switch to software testing and report to the training class for 3 months. It's a high paying job. Is it reliable?