Learn Labs
SQL & Querying

Self-test

Check your understanding

Self-test6 questions

—/6
  1. What is the difference between a CTE and a subquery for the planner in modern Postgres?

  2. Write the shape of a recursive CTE that walks an employee-manager tree, and say what stops it.

  3. How does a window function differ from GROUP BY in what it returns?

  4. What does partition pruning need from the query to work?

  5. When is a materialized view the right tool, and what does it cost to keep fresh?

  6. 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.