Files
Hui-s-notebook/203-Java/数据库/MySQL.md
2023-09-10 10:50:53 +08:00

24 lines
491 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
存储过程
函数运用
### 共享锁与排他锁
**共享锁**:只能读取不能写入,不排斥其他共享锁
```text
SELECT ... LOCK IN SHARE MODE;
```
**排它锁**:锁定后只有该线程可以读取与写入,排斥其他锁
```text
SELECT ... LOCK IN SHARE MODE;
```
Innodb 引擎修改时会加排他锁select 则不加任何锁,可通过以上方法加两种锁
### 慢 SQL 排查
- select *
- 联表
- 数据量
- 缓存
- 索引命中性(全表扫描)