[code notes] storage of a temporary table
One sentence summary
A temporary table could reside within a temporary tablespace, utilizing a temporary name in a temporary schema or namespace.
More
create
-
在一个会话第一次执行
create temp table命令时,内核会执行InitTempTableNamespace, 创建
临时 schema/namespace.
![image]()
临时 namespace 的命名为
pg_temp_<MyBackendId>, 如 pg_temp_4. -
可以通过 temp_tablespaces GUC 参数配置临时表存放在哪个表空间,默认 pg_default
code pathDefineRelation GetDefaultTablespace PrepareTempTablespaces -- step over GetNextTempTableSpace![image]()
-
临时表对应的物理文件的名字通过函数
GetNewRelFileNode获得, 命名格式为t<MyBackendId>_<oid>. 最终通过RelationCreateStorage创建对应从存储,目前内核唯一支持的存储为磁盘文件。可以通过 SQL 函数pg_relation_filepath查看存储路径。
drop
when does temp table get dropped?

posted on 2024-06-28 16:39 winter-loo 阅读(25) 评论(0) 收藏 举报


浙公网安备 33010602011771号