22.6. Snapshot-Based Isolation and Atomicity #
Postgres Pro AXE uses snapshots for isolating SQL commands and stored procedures executed on its objects. Snapshots are monotonically increasing numbers that determine object visibility. Each object has begin_snapshot and end_snapshot fields in the corresponding metadata table. The begin_snapshot field is set when the object is created, and the end_snapshot field is set when the object is deleted.
When an SQL command or stored procedure starts executing, it obtains the maximum snapshot number from the metadata catalog. This number determines which metadata catalog objects are visible: an object is visible if its begin_snapshot field is less than or equal to this number, and its end_snapshot field is not set.
You can read metadata using a specific snapshot number. To determine which metadata catalog objects are visible for a snapshot, ensure that the begin_snapshot field of the object is less than or equal to the snapshot number, and the end_snapshot field of the object is greater than the snapshot number or is not set.
Example 22.6. Retrieving Parquet Files Using a Specific Snapshot Number
SELECT data.path AS data_file_path
FROM axe_catalog.axe_data_file AS data
WHERE
data.table_id = 42 AND
15 >= data.begin_snapshot AND
(15 < data.end_snapshot OR data.end_snapshot IS NULL)
ORDER BY file_order;