# 4.5 The Looking Glass Windows (Isolation Levels) ![Isolation Levels](assets/arch_isolation_windows.png) Now that we understand the [[Chapter 4/4.4 - Transactions|Pinky Swear]], we need to talk about the **view**. When you step into a **Looking Glass Room** (a Transaction), the Lazy Elephant has to decide exactly how much of the outside Depot you are allowed to see through the windows. This is known as the **Isolation Level**, and Postgres offers three distinct types of windows. ## 1. Read Committed (The Standard Window) This is the default view. The window is clear, but it only shows what people have *finished* (committed). Imagine you look out the window and see a red suitcase sitting on a cart. You blink, and in that split second, another elephant commits a change that swaps it for a blue suitcase. When you look again, the red one is gone! This is called a **Non-repeatable Read**. Because the window is "live" to committed changes, your view can change mid-transaction. It’s fast, it’s low-effort for the elephant, and for 99% of tasks, it’s exactly what you need. ## 2. Repeatable Read (The Magic Painting) If you need more stability, you ask for a **Repeatable Read**. The moment you step into the room, the elephant takes a high-resolution Polaroid of the entire Depot and tapes it over the window. This is **Snapshot Isolation**. No matter how many suitcases are moved, added, or burned outside, your "Magic Painting" never changes. You see the world exactly as it was the moment your pinky swear began. Even if you look a thousand times, that red suitcase will stay red. Be warned: if you try to update a suitcase that someone else changed while you were looking at your painting, the elephant will scream and cancel your transaction! He hates paradoxes. ## 3. Serializable (The Single-File Door) This is the "Old School" level of safety. It handles the terrifying **Phantom Read**—the suitcase that wasn't there when you counted them, but suddenly appeared when you tried to close the door. In **Serializable** mode, the elephant doesn't just give you a painting; he monitors every single piece of data you touch. He keeps a secret list of "Dependencies." If he realizes that your work and someone else's work could possibly conflict in a way that breaks the laws of physics, he will immediately abort the most recent transaction with a "Serialization Failure." It’s like a bouncer who ensures that even if a hundred elephants are working, the result is the same as if they had walked through the door **one at a time, in a single-file line**. It is perfectly safe, but it makes the elephant very nervous (and can slow things down if everyone reaches for the same suitcases). --- [[Chapter 4/4.4 - Transactions|← 4.4 - Transactions]] | [[Chapter 4/4.0 - Safety Without Sweating|↑ 4.0 - Safety Without Sweating]] | [[Chapter 5/5.0 - The Hunger of Resources|5.0 - The Hunger of Resources →]]