Brain-Score 90/100 TECH PyCon Canada · 29:40

Postgres, MVCC, and you or, Why COUNT(*) is slow (David Wolever)

3-Second Blueprint (English)

  1. PostgreSQL updates write a brand-new row tuple on disk instead of overwriting existing data in place.
  2. Sequential transaction IDs (xid) with xmin and xmax metadata determine which row versions each transaction sees.
  3. Because tuple visibility varies per transaction, COUNT(*) must check live rows rather than read one cached total.
PostgreSQL MVCCTransaction ID (xid)Tuple Visibility (xmin/xmax)EXPLAIN Cost EstimatesVACUUM & XID Wraparound

3-Sekunden-Fazit (Deutsch)

  1. Bei Updates überschreibt PostgreSQL Zeilen nicht direkt, sondern hängt ein neues Tupel auf der Festplatte an.
  2. Fortlaufende Transaktions-IDs (xid) samt xmin/xmax steuern, welche Zeilenversionen für jede Transaktion sichtbar sind.
  3. Da Sichtbarkeit je Transaktion variiert, muss COUNT(*) gültige Tupel prüfen statt einen festen Zähler auszulesen.
PostgreSQL MVCCTransaktions-ID (xid)Tupel-Sichtbarkeit (xmin/xmax)EXPLAIN-KostenschätzungVACUUM & XID-Wraparound

Note / Hinweis: Blueprints are AI-generated educational summaries (0% Politics · 0% Religion · 0% Brainrot) and do not constitute medical, legal, or financial advice. / KI-generierte Zusammenfassung zu Bildungszwecken – ersetzt keine medizinische, rechtliche oder finanzielle Fachberatung.