Updated on 2024-06-07 GMT+08:00

Enhanced TOAST O&M Management

Use gs_parse_page_bypath to parse the TOAST pointer information in the main table.

gaussdb=#  SELECT ctid,next_chunk,chunk_seq FROM pg_toast.pg_toast_part_17559;
 ctid  | next_chunk | chunk_seq
-------+------------+-----------
 (0,1) | (0,0)      |         1
 (0,2) | (0,1)      |         0
 (0,3) | (0,0)      |         1
 (0,4) | (0,3)      |         0
(4 rows)
gaussdb=#  SELECT gs_parse_page_bypath((SELECT * FROM pg_relation_filepath('test_toast')),0,'uheap',false);
                       gs_parse_page_bypath
------------------------------------------------------------------
 ${data_dir}/gs_log/dump/1663_13113_17603_0.page
(1 row)

The parsing file 1663_13113_17603_0.page stores the TOAST pointer information as follows:

Toast_Pointer:
 column_index: 1  
		toast_relation_oid: 17608    -- OID of the out-of-line storage table
		ctid: (4, 1)                -- Head pointer of the out-of-line storage data linked list
		bucket id: -1                -- Bucket ID information
 column_index: 2
  toast_relation_oid: 17608
  ctid: (2, 1)                    
  bucket id: -1

Query enhanced TOAST data. You can determine the integrity of the link structure based on the queried enhanced TOAST table data.

gaussdb=#  SELECT ctid,next_chunk,chunk_seq FROM pg_toast.pg_toast_part_17559;
 ctid  | next_chunk | chunk_seq
-------+------------+-----------
 (0,1) | (0,0)      |         1
 (0,2) | (0,1)      |         0
 (0,3) | (0,0)      |         1
 (0,4) | (0,3)      |         0
(4 rows)