Skip to content

Commit d67e71c

Browse files
committed
C on tableAM
1 parent 022655c commit d67e71c

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/backend/catalog/index.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3221,7 +3221,11 @@ IndexCheckExclusion(Relation heapRelation,
32213221
indexInfo->ii_PredicateState = NULL;
32223222
}
32233223

3224-
3224+
/**
3225+
validate_index 是 PostgreSQL 中用于支持并发索引构建的核心函数之一。
3226+
并发索引构建允许在*不阻塞表的插入、更新和删除操作的情况下*创建索引,从而提高系统的可用性和并发性能。
3227+
该函数的主要任务是验证索引的完整性(通过两次表扫描),确保所有符合条件的元组都被正确地索引。
3228+
*/
32253229
/*
32263230
* validate_index - support code for concurrent index builds
32273231
*

src/backend/executor/nodeSamplescan.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
15+
16+
/**
17+
Sample Scan 是 PostgreSQL 中用于表采样的功能,通过 TABLESAMPLE 子句实现。
18+
它允许用户从表中随机抽取部分数据,适用于统计分析、查询优化和测试等场景。
19+
在 PostgreSQL 的实现中,nodeSamplescan.c 文件定义了 Sample Scan 的核心逻辑,包括初始化、采样和资源释放等操作。
20+
通过支持多种采样方法和参数,Sample Scan 提供了灵活且高效的数据采样能力
21+
22+
ubuntu=# select * from bar TABLESAMPLE BERNOULLI (20);
23+
a
24+
---
25+
1
26+
7
27+
9
28+
(3 rows)
29+
30+
*/
31+
1532
#include "postgres.h"
1633

1734
#include "access/relscan.h"

src/include/access/tableam.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,6 +1644,11 @@ table_relation_set_new_filelocator(Relation rel,
16441644
minmulti);
16451645
}
16461646

1647+
/**
1648+
table_relation_nontransactional_truncate 是一个静态内联函数,用于以非事务性的方式清空指定表(rel)的所有内容。
1649+
非事务性操作意味着该函数不支持回滚,因此一旦执行,操作的效果将是不可逆的。
1650+
这种设计通常用于特定场景,例如在当前事务中创建的临时存储对象的截断操作。
1651+
*/
16471652
/*
16481653
* Remove all table contents from `rel`, in a non-transactional manner.
16491654
* Non-transactional meaning that there's no need to support rollbacks. This

0 commit comments

Comments
 (0)