DSA Factory
Free Indexes, queries and scale lessonsIndexes, queries and scale · Stage 2 · Executing queries · Step 1

Query plans and join algorithms

Read a plan as a tree of operators, and compare nested-loop, block nested-loop and hash joins by their page cost. About 15 minutes.

Quick check

Two large tables with no useful index are joined on an equality condition. Which method is usually cheapest?

  1. AHash join
  2. BPage nested loop
  3. CIndex nested loop
Show the answer

Hash join. Cost grows with the sum of the sizes, not their product.

Lock it in

4 questions on this idea

Short questions that apply the idea to new cases: trace it, work out a number, put steps in order. A wrong answer explains itself.

Answer them in your browserFree account, no card. Your progress is saved, and the idea comes back in a quick review later.
Sign up free to solve