Bird
0
0

You want to refresh a materialized view mv_inventory that depends on multiple large tables. To minimize downtime and keep data consistent, which strategy is best?

hard📝 Application Q9 of 15
PostgreSQL - Views and Materialized Views

You want to refresh a materialized view mv_inventory that depends on multiple large tables. To minimize downtime and keep data consistent, which strategy is best?

AManually update the materialized view with partial data
BRun <code>REFRESH MATERIALIZED VIEW mv_inventory;</code> during peak hours
CDrop and recreate the materialized view daily
DUse <code>REFRESH MATERIALIZED VIEW CONCURRENTLY mv_inventory;</code> and ensure a unique index exists
Step-by-Step Solution
Solution:
  1. Step 1: Consider minimizing downtime and consistency

    Concurrent refresh allows updates without blocking reads and keeps data consistent.
  2. Step 2: Check requirements for concurrent refresh

    A unique index on the materialized view is required for concurrent refresh.
  3. Final Answer:

    Use REFRESH MATERIALIZED VIEW CONCURRENTLY mv_inventory; and ensure a unique index exists -> Option D
  4. Quick Check:

    Concurrent refresh with unique index = best strategy [OK]
Quick Trick: Concurrent refresh needs unique index for minimal downtime [OK]
Common Mistakes:
  • Refreshing during peak hours blocks users
  • Dropping and recreating causes downtime
  • Partial manual updates risk inconsistency

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes