Bird
0
0

You want to combine the benefits of a materialized view and a regular view by having fast queries and always fresh data. Which approach is best?

hard📝 Application Q9 of 15
PostgreSQL - Views and Materialized Views
You want to combine the benefits of a materialized view and a regular view by having fast queries and always fresh data. Which approach is best?
AUse a materialized view and refresh it manually after every data change.
BUse a regular view and cache the results in the application layer.
CUse a regular view with indexes on base tables for faster queries.
DUse a materialized view with a trigger to refresh automatically on data changes.
Step-by-Step Solution
Solution:
  1. Step 1: Understand limitations of materialized views

    Materialized views need manual or automated refresh to update data.
  2. Step 2: Use triggers for automatic refresh

    Setting triggers to refresh materialized views on data changes combines freshness and speed.
  3. Final Answer:

    Use a materialized view with a trigger to refresh automatically on data changes. -> Option D
  4. Quick Check:

    Auto-refresh materialized view = B [OK]
Quick Trick: Triggers can automate materialized view refresh for fresh data [OK]
Common Mistakes:
  • Assuming manual refresh is always sufficient
  • Believing regular views with indexes match materialized view speed
  • Ignoring application caching complexity

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes