0Pricing
PostgreSQL Performance & Query Optimization · Lektion

EXPLAIN- und EXPLAIN-ANALYZE-Ausgaben lesen

Entschlüsseln Sie PostgreSQL-Abfragepläne mit EXPLAIN, um zu sehen, wie der Planer eine Abfrage ausführt und wo die Zeit tatsächlich anfällt.

EXPLAIN- und EXPLAIN-ANALYZE-Ausgaben lesen ist eine kostenlose PostgreSQL Performance & Query Optimization-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des PostgreSQL Performance & Query Optimization-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der PostgreSQL Performance & Query Optimization-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Why Read Query Plans

Before tuning a slow query, see what PostgreSQL actually does. EXPLAIN shows the planner's chosen execution plan as a tree of nodes.

EXPLAIN vs EXPLAIN ANALYZE

EXPLAIN shows estimates only; EXPLAIN ANALYZE actually runs the query and reports real timings and row counts — far more useful for diagnosis.

EXPLAIN ANALYZE
SELECT * FROM orders WHERE customer_id = 42;

The Plan Tree

Read plan trees inside-out and bottom-up: leaf nodes scan data, parents join or aggregate. Each node reports its cost, rows, and width.

The cost Numbers

The cost reads as cost=0.00..18.45: first is startup cost, second is total, both in arbitrary planner units used to compare competing plans.

Sequential Scan

A Seq Scan reads the whole table — fine for small tables or when most rows match, but a red flag on a selective query over a large one.

Index Scan

An Index Scan uses an index to find matching rows, then fetches them from the table. It's the win for selective predicates.

Estimated vs Actual Rows

Compare estimated rows with actual rows. A big mismatch means stale statistics and often a bad plan — run ANALYZE to refresh them, as shown below.

ANALYZE orders;

Spotting the Bottleneck

To find the bottleneck, hunt for the node with the largest actual time, or one whose loops multiply its cost. That's where to focus tuning.

BUFFERS for I/O Insight

Add BUFFERS to your EXPLAIN to see how many pages came from cache versus disk — the fast way to spot I/O-bound queries. See the example below.

EXPLAIN (ANALYZE, BUFFERS)
SELECT * FROM orders WHERE total > 100;

Join Strategies

Watch the join strategy: Nested Loop, Hash Join, or Merge Join. A Nested Loop over many rows without an index is a classic slow pattern.

Readable Formats

For big plans, switch to FORMAT JSON or a visual tool to explore them more easily. The query below shows the JSON option.

EXPLAIN (ANALYZE, FORMAT JSON)
SELECT * FROM orders;

Quick Check

Test what you have learned.

Recap

Recap: read EXPLAIN trees, compare estimates with ANALYZE actuals, tell Seq from Index scans and join types, use BUFFERS, and find the bottleneck node.

Häufig gestellte Fragen

Ist die Lektion „EXPLAIN- und EXPLAIN-ANALYZE-Ausgaben lesen“ kostenlos?

Ja — der vollständige Text von „EXPLAIN- und EXPLAIN-ANALYZE-Ausgaben lesen“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des PostgreSQL Performance & Query Optimization-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der PostgreSQL Performance & Query Optimization-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „EXPLAIN- und EXPLAIN-ANALYZE-Ausgaben lesen“?

Entschlüsseln Sie PostgreSQL-Abfragepläne mit EXPLAIN, um zu sehen, wie der Planer eine Abfrage ausführt und wo die Zeit tatsächlich anfällt. Du übst PostgreSQL Performance & Query Optimization mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um PostgreSQL Performance & Query Optimization zu starten?

Keine Vorkenntnisse erforderlich. PostgreSQL Performance & Query Optimization auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „EXPLAIN- und EXPLAIN-ANALYZE-Ausgaben lesen“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser PostgreSQL Performance & Query Optimization-Lektion Code schreiben und ausführen?

Ja. Jede PostgreSQL Performance & Query Optimization-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Grundlagen der Datenbankleistung verstehen
  2. Überblick über die PostgreSQL-Architektur
  3. Grundlegender Ablauf der Abfrageausführung
  4. EXPLAIN- und EXPLAIN-ANALYZE-Ausgaben lesen
← Zurück zu PostgreSQL Performance & Query Optimization