A Materialized View Precomputes an Expensive Query and Bills You for the Refresh
A materialized view stores the result of a query as a real table, so a dashboard aggregate that takes thirty seconds becomes a millisecond lookup. The cost moves rather than disappearing: the result is only as fresh as the last REFRESH MATERIALIZED VIEW, a plain refresh locks readers out while it runs unless you use CONCURRENTLY with a unique index, and you now own a refresh schedule that can fail. Reach for one when the query is already well written and well indexed, the answer changes far less often than it is read, and the business can accept an answer that is minutes old.
Questions this Concept answers
- Why is a materialized view described as moving the cost rather than removing it?
Storing Query Results in a Materialized View and Refreshing It in SQL
A materialized view is a database object defined over a query that stores both the query definition and the result rows it produced, so reading it returns stored data instead of re-executing the quer…