Bird
0
0

You created a materialized view but notice it shows outdated data after the underlying table changes. What is the best way to fix this?

medium📝 Debug Q14 of 15
PostgreSQL - Views and Materialized Views
You created a materialized view but notice it shows outdated data after the underlying table changes. What is the best way to fix this?
AUse SELECT * FROM materialized_view to refresh automatically.
BDrop and recreate the materialized view every time.
CRestart the PostgreSQL server to refresh views.
DRun REFRESH MATERIALIZED VIEW to update the data.
Step-by-Step Solution
Solution:
  1. Step 1: Identify how to update materialized view data

    Materialized views do not auto-update; REFRESH MATERIALIZED VIEW command updates stored data.
  2. Step 2: Evaluate other options

    Dropping and recreating the materialized view every time is inefficient, using SELECT * FROM materialized_view does not refresh it, restarting the PostgreSQL server is unrelated.
  3. Final Answer:

    Run REFRESH MATERIALIZED VIEW to update the data. -> Option D
  4. Quick Check:

    Use REFRESH MATERIALIZED VIEW to update data [OK]
Quick Trick: Use REFRESH MATERIALIZED VIEW to update stored data [OK]
Common Mistakes:
  • Expecting SELECT to refresh data automatically
  • Dropping and recreating instead of refreshing
  • Restarting server to fix view data

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes