Udemy
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
SQL Query Optimisation - Practice Tests
26 students

SQL Query Optimisation - Practice Tests

Fix slow queries, and ace performance interviews with 300 scenario-based practice questions.
Created byTech Coach
Last updated 6/2026
English

What you'll learn

  • Diagnose slow queries using EXPLAIN ANALYZE: read plan nodes, spot cardinality errors, identify the slow node, and interpret buffer and timing data.
  • Recognise and fix the most costly SQL anti-patterns: leading wildcards, implicit type casts, functions on indexed columns, and OFFSET pagination.
  • Choose the right join strategy, aggregation method, and index type for a given query and explain why the planner picks one plan over another.
  • Rewrite inefficient queries using window functions, CTEs, cursor pagination, conditional aggregation, and semi-join patterns that scale to hundreds of millions

Included in This Course

300 questions
  • Parser, Planner & Execution Engine50 questions
  • Indexes: Types, Selection & Common Mistakes50 questions
  • Join Optimisation & Execution Strategies50 questions
  • Aggregations, Window Functions & Subquery Patterns50 questions
  • Anti-patterns & Rewrites50 questions
  • Reading & Interpreting Query Execution Plans50 questions

Description

Slow queries cost money, fail interviews, and get flagged in code review. This course gives you 300 practice questions built around the SQL performance skills that actually come up in senior engineering roles and production incidents.

The six tests cover the full optimisation stack, from fundamentals to expert-level plan reading:

Test 1 covers how databases actually execute queries: the parser, planner, and execution engine. You will understand what the cost model is, how statistics drive plan choice, and why the same SQL can run in 2ms one day and 2 minutes the next.

Test 2 covers indexes: B-tree, GIN, partial, composite, expression, and covering indexes. You will learn which index type fits which query pattern and the common mistakes that make indexes invisible to the planner.

Test 3 covers join optimisation. Nested loop, hash join, merge join, semi-joins, anti-joins, LATERAL, and multi-table join order. You will learn when each strategy wins and how to spot the ones causing fan-out disasters in production.

Test 4 covers aggregations, window functions, and subquery patterns. HashAggregate versus GroupAggregate, COUNT DISTINCT at scale, ROW_NUMBER versus DISTINCT ON, correlated subquery rewrites, and CTE inlining behaviour in PostgreSQL 12 and later.

Test 5 covers anti-patterns and rewrites. Leading wildcard LIKE, implicit type casts, functions on indexed columns, OFFSET pagination, NULL comparison mistakes, bulk DELETE performance, and N+1 queries. Each question presents a real-world slow query and asks you to identify the cause and the fix.

Test 6 covers reading and interpreting EXPLAIN ANALYZE output. You will learn to read plan nodes bottom-up, calculate total node work from loops and actual time, diagnose spills to disk from Batches and Sort Method, identify cardinality errors from estimated versus actual row counts, and distinguish lock waits from I/O bottlenecks.

Every question is scenario-based: a realistic production situation, four plausible answers, and a detailed explanation that goes beyond the correct answer to explain why each wrong answer fails.

Who this course is for:

  • Backend developers and data engineers who write SQL daily and want to stop guessing why queries are slow. Ideal for anyone preparing for a senior engineering role where query performance comes up in interviews or code review. Also suits analysts who have moved beyond writing correct SQL and want to write fast SQL.