Cookbook recipe

How MVCC decides which row version you see

Applies to PostgreSQL 13–17 Last reviewed May 2026 Grounded in source
Estimated investigation4 min

Scenario

Two sessions read the same row and see different values. That is MVCC — each transaction sees a consistent snapshot, not the latest write. Diagnose it Peek at the hidden version columns: SELECT xmin, xmax, *…

Investigation Path

Two sessions read the same row and see different values. That is MVCC — each transaction sees a consistent snapshot, not the latest write.

Diagnose it

Peek at the hidden version columns:

SELECT xmin, xmax, * FROM accounts WHERE id = 1;

Why it happens

Every row version carries xmin (creating transaction) and xmax (deleting/updating transaction). Your snapshot decides which versions are visible: those committed before your snapshot and not yet deleted within it.

This is a Pro lesson

Get every Learning Pathway and cookbook recipe — grounded in PostgreSQL source code, with diagnostics, fixes, and prevention for each topic.

Continue this lesson to learn:

  • How to fix it
  • Prevent it next time
  • Related & next steps
  • All 36 Learning Pathway lessons
  • 170+ cookbook recipes
  • Source-grounded diagnostics & fixes

Secure checkout Cancel anytime Source-grounded

Career Impact

This scenario builds production judgment and operational confidence under pressure.

Open Career Dashboard →

Keep going

Related & next steps

Was this helpful?

← All cookbook recipes