SQL & Querying
Self-test
Check your understanding
Self-test6 questions
—/6
What is the difference between a CTE and a subquery for the planner in modern Postgres?
Write the shape of a recursive CTE that walks an employee-manager tree, and say what stops it.
How does a window function differ from GROUP BY in what it returns?
What does partition pruning need from the query to work?
When is a materialized view the right tool, and what does it cost to keep fresh?
- Design question
Design a schema for an events table that grows by 50 million rows a month and is queried mostly for the last 7 days. Include partitioning and how old data is removed.