We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
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
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by 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
It is easy and good
“It is really nice and good Please join the course”
The chapter ended with nine products and one axis: where the copy lives. A materialised view is a cache that lives in the database, and an ordinary view stores nothing at all.
That difference is the single most common misunderstanding about views, and it matters because the feature that does store something behaves like every cache in the previous chapter.

Against a real PostgreSQL holding two million rows. The left panel is a saved query the planner pastes into whatever referenced it. The right is a table somebody already filled in.

Every timing is the execution time reported by EXPLAIN ANALYZE against a database this lab started and tore down.

That is a stronger claim than the two timings being close, and it is what the lab actually checked.
Compare plans, not timings, whenever the claim is that two things are the same query. A timing tells you they were similar on one machine on one afternoon; an identical plan tells you the database made no distinction at all.

Because the view is pasted in before planning, the optimiser sees one query over one table with two conditions on it, and is free to use whatever index serves them best.
This is why views are usually free. They are not a layer the query passes through, they are a piece of text that stops existing before any decision is made.