Bird
0
0

Given a materialized view created as:

medium📝 query result Q13 of 15
PostgreSQL - Views and Materialized Views
Given a materialized view created as:
CREATE MATERIALIZED VIEW sales_summary AS SELECT region, SUM(amount) AS total FROM sales GROUP BY region;
What will be the result of:
SELECT * FROM sales_summary;
immediately after creation?
AThe aggregated total sales per region based on current data.
BAn error because materialized views need manual refresh first.
CEmpty result set because no data is stored yet.
DThe detailed sales rows without aggregation.
Step-by-Step Solution
Solution:
  1. Step 1: Understand materialized view creation behavior

    When created, a materialized view stores the query result immediately.
  2. Step 2: Determine output of SELECT from materialized view

    It returns the aggregated totals per region as per the query at creation time.
  3. Final Answer:

    The aggregated total sales per region based on current data. -> Option A
  4. Quick Check:

    Materialized view stores query result on creation [OK]
Quick Trick: Materialized views store data on creation, so SELECT returns stored results [OK]
Common Mistakes:
  • Thinking materialized views are empty until refreshed
  • Expecting detailed rows instead of aggregated results
  • Assuming errors occur without manual refresh

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes