# 3.1 The Lazy General's Map (Planning)

Before the first soldier takes a single step, the Lazy General must confront a
terrifying truth: your query is not a command; it is a **Riddle**.
In the database warehouse, there is almost never just "one way" to find a piece
of data. If you are looking for a red suitcase, you could walk every single
aisle (a [[Postgres/Operations/SeqScan|Sequential Scan]]), or you could check
the librarian's map (an [[Postgres/Chapter 2/2.1 - The B-Tree (The Librarian's
Map)|Index Scan]]). For a complex question involving three people and their
luggage, there are literally millions of possible "paths" through the aisles.
The General's job is **The Algebra of Paths**. He treats your query like a
mathematical formula that can be rearranged and warped. He doesn't make these
decisions based on "vibes" or intuition; he makes them based on a rigid
**Imperial Ledger of Costs** grounded in the harsh reality of
[[Postgres/Resources/_Resources|Elephant Time]].
## The Cost of Cold Winters
The General knows that while a thought in his head takes only a microsecond, a
single trip to the frozen basement ([[Postgres/Resources/Disk IO|Disk IO]]) is
the equivalent of a **4-month-long winter expedition**.
He assigns points to every action:
- **Sequential Page Read**: 1.0 points (Walking down a known path).
- **Random Page Read**: 4.0 points (Stumbling through a dark forest).
- **CPU Tuple Processing**: 0.01 points (Opening a suitcase).
- **Index Tuple Processing**: 0.005 points (Checking a post-it note).
## The Probability Game
The General maintains massive **Histograms** (his "cheat sheets") about your
data. If you ask for all rows where `age > 99`, he checks his sheets, realizes
that exactly 0.01% of people are over 99, and immediately concludes that using
an index is cheaper than walking through the entire warehouse.
But the General is only as good as his map. If you haven't performed an
[[ANALYZE]] recently, his map will be outdated, and he might send an army of
elephants to move a single matchstick.
For the deep mathematical specs on these cost constants, see the
[[Postgres/Chapter 5 - The Hunger of Resources|Resources Chapter]].