---
title: "Reading a Query Plan"
description: "The database chooses how to run a query: which index to use, which join method, in what order. The plan is that choice written down with estimated row counts, and reading it is how a slow query stops "
canonical: https://lightmysky.com/learn/computing/reading-a-query-plan-mt_spbbzsCoBB
source: https://lightmysky.com/learn/computing/reading-a-query-plan-mt_spbbzsCoBB.md
retrieved: 2026-09-12
---

> **Agent view.** This is the Markdown twin of the page, for tools and assistants.
> When to use this site, and the call that answers each job: https://lightmysky.com/agent-instructions.md
> API description (OpenAPI 3.1): https://lightmysky.com/openapi.json · Authentication: https://lightmysky.com/auth.md
> Pricing: https://lightmysky.com/pricing.md · Catalog: https://lightmysky.com/llms.txt · Full catalog: https://lightmysky.com/llms-full.txt
> Every machine-readable file on this domain: https://lightmysky.com/.well-known/ai-catalog.json
> Ask for Markdown with `Accept: text/markdown`, a `.md` address, or `?mode=agent`.

# Reading a Query Plan

The database chooses how to run a query: which index to use, which join method, in what order. The plan is that choice written down with estimated row counts, and reading it is how a slow query stops being a mystery.

Subject: Computing · Area: Data & Databases · Ages 19 to 21
Page: https://lightmysky.com/learn/computing/reading-a-query-plan-mt_spbbzsCoBB

## Ready when they can

- Read a plan and name the access method chosen for each table
- Find the step where the estimated row count disagrees with reality
- Explain why a nested loop join beats a hash join on small inputs

## Lesson: Reading the plan behind a slow query

A query plan is the database choice written down. It names the access method for each table, the join method, and the join order. Each step carries an estimated row count.

The access method is how one table is read. An index scan follows an index to a few rows. A full scan reads the whole table, which wins when most rows qualify.

**Example.** A plan shows a full scan feeding a join, estimating 10 rows while 10,000 rows really arrive. The wrong estimate picked the wrong method, and that step costs the most.

**Tip.** A nested loop join wins on small inputs because it needs almost no setup. On big inputs a hash join wins instead. To fix the costly step, correct the estimate, add the missing index, or change the join order.

**Recap.** Read the plan, check each estimate against reality, and fix the step that lies.

## Practice

8 questions on this page, each with its working shown.

## Needs first

- [Indexes: B-Trees and the Cost of a Lookup](https://lightmysky.com/learn/computing/indexes-b-trees-and-the-cost-of-a-lookup-mt_1Z5EQTqooI)
- [Asymptotic Notation Made Precise](https://lightmysky.com/learn/computing/asymptotic-notation-made-precise-mt_B0Z6Syy8Ve)

## Opens up

- [Transactions and the ACID Promise](https://lightmysky.com/learn/computing/transactions-and-the-acid-promise-mt_8Egjmafq-L)
