forked from qyuhen/book
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MySQL
49 lines (38 loc) · 1.38 KB
/
MySQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|pages |date |minutes |
|--- |--- |--- |
|1,5 |2024.7.29 |30min |
## How does MySQL work?
* plugin
* logical architecture
* storage engine: provide API, respond to requests from the server
* one connetion occupy one thread (threads are cached)
* Connection Management and Security
* Optimization and Execution
* Concurrency Control: read/write locks, lock granularity, table locks
* transaction logging: sequential IO
## AUTOCOMMIT
有些命令会导致事务提交,比如某些ddl语句,alter table
* two-phase locking protocol
* implicit and explicit locking
lock in share mode
for update
lock tables, unlock tables (on server level, not on storage engine)
## MVCC
innodb, oracle, postgresql
avoid locking, lover overhead
see different data at the same time!
store version number
example
read the version of the row before or equal to current transaction
该版本的数据(一定是当前事务之前开始,并且在当前事务之前提交的, 正在进行的事务还没提交,因此也看不到)
be responsible for doing sth.
special care
locking technology
lock consume resources
xxx can suffer (受害,受到影响,不好的影响)
locking strategy
keep at bay
atomicity: either applied or rolled back (all or nothing, 不存在中间状态,完成到一半)
indivisible
reflected in database
dead lock, happen when lock same resource, but lock in different order