Skip to content

Commit

Permalink
docs: update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangfisher committed Aug 3, 2024
1 parent 79413be commit bb47373
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions docs/intro/principle.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ WHERE path LIKE '/root/A/A-2%';

闭包表结构需要两张表来表示树,一张表存储节点信息,另一张表存储节点之间的关系。如下:

- **节点表**

| id | name |
|----|------|
| 1 | root |
Expand All @@ -158,7 +160,8 @@ WHERE path LIKE '/root/A/A-2%';
| 6 | A-2 |
| 7 | A-3 |

closure 表:
- **关系表**

| ancestor | descendant | depth |
|----------|------------|-------|
| 1 | 1 | 0 |
Expand All @@ -178,11 +181,7 @@ closure 表:
| 6 | 6 | 0 |
| 7 | 7 | 0 |

- 存储空间需求大:闭包表结构需要为每个节点与其所有祖先和后代的关系都存储一条记录,因此存储空间需求较大。
- 更新操作复杂:当插入、删除或移动节点时,可能需要更新大量的祖先和后代关系,这可能会导致性能问题。
- 数据冗余:每个节点的所有祖先和后代关系都被存储了多次,存在数据冗余。
- 维护成本高:由于需要维护大量的关系记录,插入、删除和更新操作的维护成本较高。

- 从上表可以看出,为了查询某个节点的所有后代节点 每个节点需要记录其所有祖先节点,以及每个节点的深度。这样就需要更多的存储空间,且维护成本较高。



0 comments on commit bb47373

Please sign in to comment.