# 3.2 The Assembly Line (Query Algebra) ![Query Algebra](assets/arch_plan_algebra_summary.png) The Head Chef has drawn up the perfect service plan. But someone still has to go out and execute it. In Postgres, the actual physical labor is performed by a mismatched team of highly specialized **Operations** (Plan Nodes), executing what we affectionately call the **Query Algebra**. ## The Order-Driven Kitchen (The Pull Model) To understand the Staff, you must first understand how they communicate. The Postgres Execution Engine does not "push" data from the bottom up. Instead, it is an **Order-Driven Kitchen**. Imagine the top-most server (the **[[Operations/Result|Maitre D']]**) standing at the very top of the hill (or the pass). Every second, he shouts down to the staff member below him: _"Give me one plate!"_ "But I haven't finished my tea!" the lower staff member cries. "I don't care! Give me one plate, or off with your apron!" the Maitre D' responds. This "Pull" model ensures the elephant never does more work than he absolutely has to. If you only asked for the first 10 plates (a **[[Operations/Limit|Limit]]**), the Maitre D' stops shouting after the 10th plate arrives. The entire kitchen immediately puts down its tools and goes to an un-birthday party, even if there are millions of plates left to scan. It’s a very sensible way to be lazy! ## The Specialized Units The kitchen is divided into teams, each with its own quirks, strengths, and heavy machinery. We explore these specialized plan nodes in the following service manuals: ### 1. The Pantry Fetchers (Scans) ![[Chapter 3/3.2.1 - The Pantry Fetchers (Scans).md]] ### 2. The Sous Chefs (Joins) ![[Chapter 3/3.2.2 - The Sous Chefs (Joins).md]] ### 3. The Prep Station (Aggregations) ![[Chapter 3/3.2.3 - The Prep Station (Aggregations).md]] ## The Logistics and the Fog of War Every staff member in the kitchen needs a place to work. In **[[Chapter 5/5.0 - The Hunger of Resources (Memory & Disk)|Chapter 5]]**, we will explore how every staff member is given a small **Counter** (`work_mem`). If a counter is too small, a "Spill to Disk" (the Frozen Pantry) occurs—turning a fast service into a slow ordeal! Furthermore, even the best-organized kitchen runs into traffic. In **[[Chapter 6/6.0 - The Waiting Game|Chapter 6]]**, we will observe these staff members 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 Maitre D' hands you a **Service Receipt** detailing exactly how many plates were pulled and how much each staff member sweated. --- [[Chapter 3/3.1 - The Head Chef's Menu (Query Planning)|← 3.1 - The Head Chef's Menu]] | [[Chapter 3/3.0 - The Great Lunch Rush (Planning & Operations)|↑ 3.0 - The Great Lunch Rush]] | [[Chapter 3/3.2.1 - The Food Runners (Scans)|3.2.1 - The Pantry Fetchers (Scans) →]]