云数据库 GAUSSDB-Enhanced Toast相关DDL操作
Enhanced Toast相关DDL操作
Enhanced Toast表的创建
建表时指定Toast表的存储类型为Enhanced Toast或者Toast:
gaussdb=# CREATE TABLE test_toast (id int, content text) WITH(toast.toast_storage_type=toast); CREATE TABLE gaussdb=# \d+ test_toast Table "public.test_toast" Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+----------+--------------+------------- id | integer | | plain | | content | text | | extended | | Has OIDs: no Options: orientation=row, compression=no, storage_type=USTORE, segment=off, toast.storage_type=USTORE, toast.toast_storage_type=toast gaussdb=# drop table test_toast; DROP TABLE gaussdb=# CREATE TABLE test_toast (id int, content text) WITH(toast.toast_storage_type=enhanced_toast); CREATE TABLE gaussdb=# \d+ test_toast Table "public.test_toast" Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+----------+--------------+------------- id | integer | | plain | | content | text | | extended | | Has OIDs: no Options: orientation=row, compression=no, storage_type=USTORE, segment=off, toast.storage_type=USTORE, toast.toast_storage_type=enhanced_toast gaussdb=# DROP TABLE test_toast; DROP TABLE
建表时不指定线外存储表的类型,则创建线外存储表类型依赖于GUC参数enable_enhance_toast_table:
gaussdb=# show enable_enhance_toast_table; enable_enhance_toast_table ---------------------------- on (1 row) gaussdb=# CREATE TABLE test_toast (id int, content text); CREATE TABLE gaussdb=# \d+ test_toast Table "public.test_toast" Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+----------+--------------+------------- id | integer | | plain | | content | text | | extended | | Has OIDs: no Options: orientation=row, compression=no, storage_type=USTORE, segment=off, toast.storage_type=USTORE, toast.toast_storage_type=enhanced_toast gaussdb=# DROP TABLE test_toast; DROP TABLE gaussdb=# SET enable_enhance_toast_table = off; SET gaussdb=# show enable_enhance_toast_table; enable_enhance_toast_table ---------------------------- off (1 row) gaussdb=# CREATE TABLE test_toast (id int, content text); CREATE TABLE gaussdb=# \d+ test_toast Table "public.test_toast" Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+----------+--------------+------------- id | integer | | plain | | content | text | | extended | | Has OIDs: no Options: orientation=row, compression=no, storage_type=USTORE, segment=off, toast.storage_type=USTORE, toast.toast_storage_type=toast gaussdb=# DROP TABLE test_toast; DROP TABLE
线外存储表结构的升级
当GUC参数“enable_enhance_toast_table=on”时,线外存储表支持通过Vacuum Full操作将Toast升级为Enhanced Toast结构。
gaussdb=# CREATE TABLE test_toast (id int, content text); CREATE TABLE gaussdb=# \d+ test_toast Table "public.test_toast" Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+----------+--------------+------------- id | integer | | plain | | content | text | | extended | | Has OIDs: no Options: orientation=row, compression=no, storage_type=USTORE, segment=off, toast.storage_type=USTORE, toast.toast_storage_type=toast gaussdb=# VACUUM FULL test_toast; VACUUM gaussdb=# \d+ test_toast Table "public.test_toast" Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+----------+--------------+------------- id | integer | | plain | | content | text | | extended | | Has OIDs: no Options: orientation=row, compression=no, storage_type=USTORE, segment=off, toast.storage_type=USTORE, toast.toast_storage_type=enhanced_toast gaussdb=# DROP TABLE test_toast; DROP TABLE
分区表merge操作
支持将分区表的分区间不同的线外存储表类型进行合并操作。
- 对于相同类型的线外存储分区,合并与原有逻辑保持一致,进行物理合并。
- 对于不同类型的线外存储分区,合并后的分区线外存储表为Enhanced Toast表,需要进行逻辑合并,性能劣于物理合并。
gaussdb=# CREATE TABLE test_partition_table(a int, b text)PARTITION BY range(a)(partition p1 values less than (2000),partition p2 values less than (3000)); gaussdb=# SELECT relfilenode FROM pg_partition WHERE relname='p1'; relfilenode ------------- 17529 (1 row) gaussdb=# \d+ pg_toast.pg_toast_part_17529 TOAST table "pg_toast.pg_toast_part_17529" Column | Type | Storage ------------+---------+--------- chunk_id | oid | plain chunk_seq | integer | plain chunk_data | bytea | plain Options: storage_type=ustore, toast_storage_type=toast gaussdb=# SELECT relfilenode from pg_partition WHERE relname='p2'; relfilenode ------------- 17528 (1 row) gaussdb=# \d+ pg_toast.pg_toast_part_17528 TOAST table "pg_toast.pg_toast_part_17528" Column | Type | Storage ------------+---------+--------- chunk_seq | integer | plain next_chunk | tid | plain chunk_data | bytea | plain Options: storage_type=ustore, toast_storage_type=enhanced_toast gaussdb=# ALTER TABLE test_partition_table MERGE PARTITIONS p1,p2 INTO partition p1_p2; ALTER TABLE gaussdb=# SELECT reltoastrelid::regclass FROM pg_partition WHERE relname='p1_p2'; reltoastrelid ------------------------------ pg_toast.pg_toast_part_17559 (1 row) gaussdb=# \d+ pg_toast.pg_toast_part_17559 TOAST table "pg_toast.pg_toast_part_17559" Column | Type | Storage ------------+---------+--------- chunk_seq | integer | plain next_chunk | tid | plain chunk_data | bytea | plain Options: storage_type=ustore, toast_storage_type=enhanced_toast gaussdb=# DROP TABLE test_partition_table; DROP TABLE
- VPN购买指导_VPN操作指南_VPN相关基本概念
- 华为云数据库 RDS for MySQL常见故障排除_华为云
- GaussDB操作手册_云数据库Gaussdb快速入门_高斯数据库操作手册-华为云
- 免费的MySQL数据库_免费云数据库_MySQL数据库基础知识_MySQL数据库免费下载
- GaussDB操作_GaussDB版本_高斯数据库操作
- RDS for MySQL审计日志_开启日志审计_数据库审计_华为云数据库RDS
- 云数据库专题
- GaussDB数据库SQL语法_SQL语法_CREATE_ALTER
- 云数据库 GeminiDB系统架构_免费试用云数据库
- 云数据库 RDS for MySQL版本升级_MySQL如何进行版本升级_华为云