Bird
0
0

You have a materialized view mv_orders that is refreshed daily. You want to refresh it without blocking reads and ensure the data is current. Which command should you use?

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

You have a materialized view mv_orders that is refreshed daily. You want to refresh it without blocking reads and ensure the data is current. Which command should you use?

AREFRESH MATERIALIZED VIEW mv_orders;
BREFRESH MATERIALIZED VIEW CONCURRENTLY mv_orders;
CREFRESH MATERIALIZED VIEW WITH NO DATA mv_orders;
DALTER MATERIALIZED VIEW mv_orders REFRESH CONCURRENTLY;
Step-by-Step Solution
Solution:
  1. Step 1: Identify the requirement to avoid blocking reads

    Using CONCURRENTLY allows refreshing without locking out reads on the materialized view.
  2. Step 2: Choose the correct syntax

    REFRESH MATERIALIZED VIEW CONCURRENTLY mv_orders; uses the correct syntax to refresh concurrently. REFRESH MATERIALIZED VIEW mv_orders; blocks reads, REFRESH MATERIALIZED VIEW WITH NO DATA mv_orders; does not update the data to current state, and ALTER MATERIALIZED VIEW mv_orders REFRESH CONCURRENTLY; uses incorrect command structure.
  3. Final Answer:

    REFRESH MATERIALIZED VIEW CONCURRENTLY mv_orders; -> Option B
  4. Quick Check:

    Use CONCURRENTLY to refresh without blocking reads [OK]
Quick Trick: Use CONCURRENTLY to refresh without blocking reads [OK]
Common Mistakes:
  • Using REFRESH without CONCURRENTLY causing locks
  • Trying invalid syntax with ALTER
  • Confusing WITH NO DATA option

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes