REFRESH ON COMMIT in Phoenix 5.0: When Does the MV Refresh Execute Relative to Commit?
0 reputation · 24 Dec 2024, 05:28 UTC
Phoenix 5.0 added the REFRESH ON COMMIT option to CREATE MATERIALIZED VIEW, enabling automatic view refresh after each transaction that modifies the base table. The intended behavior is that the view should be refreshed after the transaction that caused the change commits.
The goal is to pin down the exact moment the refresh operation runs: does it occur before the base‑table commit is fully applied, or does it wait until after the commit completes? Documentation states the refresh happens after the commit, but it does not clarify whether the refresh blocks the commit until it finishes or is queued afterward.
Tests in Phoenix 5.0 show that the refresh is performed synchronously, which can increase commit latency. However, the precise ordering relative to the commit’s application to the base table remains ambiguous, and the impact on isolation levels and multi‑tenant workloads is unclear.
Unresolved questions:
- Does the MV refresh run before or after the base‑table commit is fully applied?
- Is the refresh operation blocking the commit until completion, or is it queued to run afterward?