# 3.2 Query Algebra

The General has drawn up the perfect battle plan. But someone still has to go
out into the mud and execute it. In Postgres, the actual physical labor is
performed by a mismatched army of highly specialized **Operations** (Plan Nodes), executing what we affectionately call the **Query Algebra**.
## The Demand-Driven Army (The Pull Model)
To understand the Soldiers, you must first understand how they communicate. The
Postgres Execution Engine does not "push" data from the bottom up. Instead, it
is a **Demand-Driven Army**.
Imagine the top-most soldier (the **[[Operations/Result|Admiral]]**) standing at the very top of a hill. Every second, he shouts down to the soldier below him: _"Give me one row!"_
"But I haven't finished my tea!" the lower soldier cries.
"I don't care! Give me one row, or off with your head!" the Admiral responds.
This "Pull" model ensures the elephant never does more work than he absolutely has to. If you only asked for the first 10 rows (a **[[Operations/Limit|Limit]]**), the Admiral stops shouting after the 10th row arrives. The entire army immediately puts down its tools and goes to an un-birthday party, even if there are millions of suitcases left to scan. It’s a very sensible way to be lazy!
## The Specialized Units
The army is divided into companies, each with its own quirks, strengths, and heavy machinery. We explore these specialized plan nodes in the following field manuals:
### 1. The Scouts (Scans)
![[Chapter 3/3.2.1 - The Scouts (Scans).md]]
### 2. The Matchmakers (Joins)
![[Chapter 3/3.2.2 - The Matchmakers (Joins).md]]
### 3. The Organizers (Aggregations)
![[Chapter 3/3.2.3 - The Organizers (Aggregations).md]]
## The Logistics and the Fog of War
Every soldier in the army needs a place to work. In **[[Chapter 5/5.0 - The Hunger of Resources|Chapter 5]]**, we will explore how every soldier is given a small **Desk** (`work_mem`). If a desk is too small, a "Spill to Disk" occurs—turning a fast battle into a slow siege!
Furthermore, even the best-organized army runs into traffic. In **[[Chapter 6/6.0 - The Waiting Game|Chapter 6]]**, we will observe these soldiers bumping into each other (Locks) or waiting for the slow elevator to return from the basement (I/O Wait).
By using the **[[Operations/_Postgres Operations|EXPLAIN ANALYZE]]** command, the Admiral hands you a **Battle Report** detailing exactly how many rows were pulled and how much each soldier sweated.
---
[[Chapter 3/3.1 - The Lazy General's Map|← 3.1 - The Lazy General's Map]] | [[Chapter 3/3.0 - The Battle for Efficiency|↑ 3.0 - The Battle for Efficiency]] | [[Chapter 3/3.2.1 - The Scouts (Scans)|3.2.1 - The Scouts (Scans) →]]