Updated on 2025-05-29 GMT+08:00

PCR UB-Tree

Compared with the RCR UB-tree, the PCR (page consistency read) UB-tree has the following features:
  • The transaction information of the index tuple is managed by the TD slot.
  • The undo operation is added. Before insertion and deletion, the undo log needs to be written. When a transaction is aborted, the rollback operation needs to be performed.
  • Flashback is supported.

When creating an index, you can set WITH option index_txntype to pcr or set the GUC parameter index_txntype to pcr to create a PCR UB-tree. If the WITH option or GUC parameter is not specified, an RCR UB-tree is created by default. The PCR UB-tree does not support online creation, ultimate RTO replay, and standby-node read.

In the current version, it may take a long time to roll back a large number of PCR indexes. (The rollback time may increase exponentially as the data volume increases. If the data volume is too large, the rollback may fail to be completely executed.) The rollback time will be optimized in later versions. The following table describes the rollback time specifications in the current version.

Table 1 PCR index rollback time specifications

Type/Data Volume

100

1000

10,000

100,000

1 million

Rollback time with PCR indexes

0.692 ms

9.610 ms

544.678 ms

52,963.754 ms

89,440,029.048 ms

Rollback time without PCR indexes

0.226 ms

0.916 ms

8.974 ms

94.903 ms

1206.177 ms

Ratio

3.06

10.49

60.70

558.08

74,151.66

PCR UB-Tree Multi-Version Management

Different from that of RCR UB-tree, page consistency read (PCR) multi-version management is based on pages. Transaction information of all tuples is managed by the TD slot.

PCR UB-Tree Visibility Mechanism

PCR UB-tree visibility is determined by rolling back a page to a moment when the snapshot is visible to obtain a page on which all tuples are visible.

Adding, Deleting, Modifying, and Querying PCR UB-Tree

  • Insert: The operation is basically the same as that of RCR UB-tree. The difference is that a TD needs to be allocated and undo logs need to be written before insertion.
  • Delete: The operation is basically the same as that of RCR UB-tree. The difference is that a TD needs to be allocated and undo logs need to be written before deletion.
  • Update: The operation is the same as that of RCR UB-tree. That is, the operation is converted into a Delete operation and an Insert operation.
  • Scan: The operation is basically the same as that of RCR UB-tree. The difference is that the query operation needs to copy a CR page and roll back the CR page to the state visible to the snapshot. In this way, the tuples on the entire page are visible to the snapshot.

PCR UB-Tree Space Management

The space management operations are basically the same as those of RCR UB-tree. The difference is that PCR UB-tree supports flashback. Therefore, the time point when the page can be recycled is changed from OldestXmin to GlobalRecycleXid.