Skip to content

Commit

Permalink
更新 数据库结构优化
Browse files Browse the repository at this point in the history
  • Loading branch information
0xcaffebabe committed Mar 10, 2020
1 parent c984c8e commit 772005f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
Binary file added assets/2020310201126.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/2020310201242.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions 数据库系统/数据库优化.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,36 @@ show keys from table_name
- 范式化
- 反范式化
- 垂直拆分

![2020310201242](/assets/2020310201242.jpg)

使用垂直切分将按数据库中表的密集程度部署到不同的库中

- 水平拆分

![2020310201126](/assets/2020310201126.jpg)

当一个表的数据不断增多时,水平拆分是必然的选择,它可以将数据分布到集群的不同节点上,从而缓存单个数据库的压力

### 拆分策略

使用水平拆分时,操作一条数据,要在哪张表找到它

- 哈希取模
- 范围,ID范围,时间范围
- 映射表

### 拆分后的问题

- 事务
- 使用分布式事务
- 连接
- 原来的连接需要分解成多个单表查询,在应用层进行连接
- ID唯一性
- 全局唯一ID(GUID)
- 每个分片指定ID范围
- 分布式ID生成器,雪花算法

## 数据访问优化

### 减少请求的数据量
Expand Down

0 comments on commit 772005f

Please sign in to comment.