The refresh time for a PostgreSQL materialized view is longer than creating a new one.
For example, the data select query executes in 10 minutes, and creating a new materialized view takes 15 minutes. However, refreshing the same materialized view takes almost 30-35 minutes.
It has 34 million records.
-
1What's your question?mustaccio– mustaccio2024年07月24日 17:23:10 +00:00Commented Jul 24, 2024 at 17:23
1 Answer 1
Since you didn't share any details, I can only guess: you are using REFRESH MATERIALIZED VIEW CONCURRENTLY
.
Without CONCURRENTLY
, the speed would be the same as for CREATE MATERIALIZED VIEW
: the query is executed and the result materialized; the existing data file is removed.
A concurrent refresh proceeds differently: it executes the query and then performs INSERT
s, UPDATE
s and DELETE
s on the existing materialized view data as appropriate. That is more effort, but allows the view to be read while it is being refreshed.
Explore related questions
See similar questions with these tags.