May we use cookies so Meta, Google, LinkedIn and ChatGPT see your visit and we learn which ads work? PrivacyMay we use cookies to see which pages help, and let Meta, Google, LinkedIn and ChatGPT see your visit, so we know which of our ads work? That way we spend less on ads that do not work. We do not sell your data, and the site works the same if you decline. You can change your answer at any time under Cookie settings at the foot of the page. Privacy policy
Loading...
5 system design questions lean on this idea. Each walks through the full answer.
System Design Masterclass · Database Fundamentals
Free preview: the first 2 parts of this 8-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$35 once, by card or PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$35 once, by card or PayPal
See the System Design coursein Database Fundamentals
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
See where this lesson sits in the full path, with real study hours for every stage.
It is easy and good
“It is really nice and good Please join the course”
The views lesson measured what a materialized view is worth to read. The lesson measured what a derived value costs to maintain and how it drifts. Neither measured the refresh, which is where the whole operational question lives.

None of the three decisions that matter appears anywhere in CREATE MATERIALIZED VIEW.

A parallel session reads the view continuously while each refresh runs, and the worst read it saw is recorded.

The reader was not made slow. It was made to wait, because a plain REFRESH takes an ACCESS EXCLUSIVE lock and holds it until the new contents are complete.
That number is the refresh duration, not a coincidence. A reader arriving at any point during a plain refresh waits until the end of it, so the worst case is exactly how long the refresh takes.

The old contents stop being valid the moment the swap happens. Holding a lock across the whole operation is the only way that is safe.