Help Center/ GaussDB/ Feature Guide(Centralized_V2.0-3.x)/ Storage Engine/ Ustore/ Storage Format/ Index/ Inserting, Deleting, Updating, and Scanning UB-Tree
Updated on 2025-08-22 GMT+08:00

Inserting, Deleting, Updating, and Scanning UB-Tree

  • Insert: The insertion logic of UB-tree is basically not changed, except that you need to directly obtain the transaction information and fill in the xmin column during index insertion.
  • Delete: The index deletion process is added for UB-tree. The main procedure of index deletion is similar to that of index insertion. That is, obtain the transaction information, fill in the xmax column (The B-tree index does not maintain the version information so that the deletion operation is required.), and update active_tuple_count on pages. If active_tuple_count is reduced to 0, the system attempts to recycle the page.
  • Update: In Ustore, data updates require different processing on UB-tree index columns compared to Astore. Data updates include index column updates and non-index column updates. The following figure illustrates the UB-tree processing during data updates.

    The preceding figure shows the differences between UB-tree updates in index columns and non-index columns.

    1. When a non-index column is updated, the index does not change. The index tuple points to the data tuple inserted at the first time. The Uheap does not insert a new data tuple. Instead, the Uheap modifies the current data tuple and saves historical data to the undo segment.
    2. When the index column is updated, a new index tuple is inserted into UB-tree and points to the same data linepointer and data tuple. To scan the data of historical versions, you need to read it from the undo segment.
  • Scan: When reading data, you can use index to speed up scanning. UB-tree supports multi-version management and visibility check of index data. The visibility check at the index layer improves the performance of index scan and index-only scan.

    For index scan:

    1. If the index column contains all columns to be scanned (index-only scan), binary search is performed on indexes based on the scan conditions. If a tuple that meets the conditions is found, data is returned.
    2. If the index column does not contain all columns to be scanned (index scan), binary search is performed on indexes based on the scan conditions to find TIDs of the tuples that meet the conditions, and then the corresponding data tuples are found in data tables based on the TIDs. See the following figure.