0Pricing
PostgreSQL Performance & Query Optimization · Pelajaran

Membaca Keluaran EXPLAIN dan EXPLAIN ANALYZE

Uraikan rencana kueri PostgreSQL dengan EXPLAIN untuk melihat cara perencana menjalankan kueri dan ke mana sebenarnya waktu digunakan.

Membaca Keluaran EXPLAIN dan EXPLAIN ANALYZE adalah pelajaran PostgreSQL Performance & Query Optimization gratis di CoddyKit. Ini adalah pelajaran 4 dari 4. Kamu bisa membaca pelajaran lengkapnya di bawah secara gratis — lalu praktikkan langsung di browser dengan editor kode bawaan dan tutor AI 24/7. Ini adalah bagian dari jalur belajar PostgreSQL Performance & Query Optimization, dan progresmu tersinkronisasi di web dan aplikasi CoddyKit. Kursus PostgreSQL Performance & Query Optimization mencakup 4 pelajaran total.

Bagian dari pelajaran ini belum diterjemahkan dan ditampilkan dalam bahasa Inggris.

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.

Pertanyaan yang Sering Diajukan

Apakah pelajaran “Membaca Keluaran EXPLAIN dan EXPLAIN ANALYZE” gratis?

Ya — teks lengkap “Membaca Keluaran EXPLAIN dan EXPLAIN ANALYZE” gratis dibaca di sini di web. Untuk praktiknya secara interaktif (editor kode bawaan dan tutor AI 24/7) dan buka sisa kursus PostgreSQL Performance & Query Optimization, upgrade ke CoddyKit PRO. Kursus PostgreSQL Performance & Query Optimization mencakup 4 pelajaran total.

Apa yang akan aku pelajari di “Membaca Keluaran EXPLAIN dan EXPLAIN ANALYZE”?

Uraikan rencana kueri PostgreSQL dengan EXPLAIN untuk melihat cara perencana menjalankan kueri dan ke mana sebenarnya waktu digunakan. Kamu berlatih PostgreSQL Performance & Query Optimization dengan kode praktik yang langsung kamu jalankan di browser, dan tutor AI 24/7 menjawab pertanyaanmu saat kamu mengerjakan pelajaran ini.

Apakah aku perlu pengalaman untuk memulai PostgreSQL Performance & Query Optimization?

Tidak diperlukan pengalaman sebelumnya. PostgreSQL Performance & Query Optimization di CoddyKit dirancang untuk pemula hingga pelajar tingkat lanjut, jadi kamu bisa memulai di sini atau dari awal dan belajar sesuai kecepatan kamu sendiri. Ini adalah pelajaran 4 dari 4.

Berapa lama pelajaran “Membaca Keluaran EXPLAIN dan EXPLAIN ANALYZE” memakan waktu?

Sebagian besar pelajaran CoddyKit memakan waktu sekitar 5–10 menit. Setiap pelajaran ringkas dan interaktif, jadi kamu membuat kemajuan stabil dan melanjutkan dari tempat kamu tinggalkan di web dan aplikasi.

Bisakah aku menulis dan menjalankan kode dalam pelajaran PostgreSQL Performance & Query Optimization ini?

Ya. Setiap pelajaran PostgreSQL Performance & Query Optimization menyertakan editor kode bawaan, jadi kamu menulis dan menjalankan kode nyata langsung di browser dan mendapatkan umpan balik AI instan — tidak diperlukan penyiapan lokal.

Semua pelajaran dalam kursus ini

  1. Memahami Dasar-Dasar Performa Basis Data
  2. Ikhtisar Arsitektur PostgreSQL
  3. Alur Kerja Eksekusi Kueri Dasar
  4. Membaca Keluaran EXPLAIN dan EXPLAIN ANALYZE
← Kembali ke PostgreSQL Performance & Query Optimization