Class: MatViews::Services::SwapRefresh
- Inherits:
-
BaseService
- Object
- BaseService
- MatViews::Services::SwapRefresh
- Defined in:
- lib/mat_views/services/swap_refresh.rb
Overview
Service that performs a **swap-style refresh** of a materialised view.
Instead of locking the existing view, this strategy builds a new temporary materialised view and atomically swaps it in. This approach minimizes downtime and allows for safer rebuilds of large views.
Steps:
-
Create a temporary MV from the provided SQL.
-
In a transaction: rename original → old, tmp → original, drop old.
-
Recreate declared unique indexes (if any).
Options:
-
‘row_count_strategy:` (Symbol, default: :none) → one of `:estimated`, `:exact`, or `:none or nil` to control row count reporting
Returns a MatViews::ServiceResponse
Constant Summary
Constants inherited from BaseService
BaseService::ALLOWED_ROW_STRATEGIES, BaseService::DEFAULT_NIL_STRATEGY, BaseService::DEFAULT_ROW_STRATEGY, BaseService::UNKNOWN_ROW_COUNT
Instance Attribute Summary
Attributes inherited from BaseService
#definition, #request, #response, #row_count_strategy, #use_transaction
Method Summary
Methods inherited from BaseService
Constructor Details
This class inherits a constructor from MatViews::Services::BaseService