Skip to content

Postgresql Performance Tuning

Master Postgresql Performance Tuning with 103 free flashcards. Study using spaced repetition and focus mode for effective learning in Databases.

🎓 103 cards ⏱️ ~52 min Advanced
Study Full Deck →
Share: 𝕏 Twitter LinkedIn WhatsApp

🎯 What You'll Learn

Preview Questions

12 shown

How do you find the slowest queries in Postgres?

Show ▼

Enable pg_stat_statements extension. Then:

SELECT query, calls, total_exec_time, mean_exec_time FROM pg_stat_statements ORDER BY total_exec_time DESC LIMIT 20;

How do you read an EXPLAIN plan?

Show ▼

Read bottom-up: leaf nodes first (table scans / index scans), then joins, then aggregates. Look for high cost, rows, and actual time.

Difference between EXPLAIN, EXPLAIN ANALYZE, EXPLAIN (BUFFERS, ANALYZE)?

Show ▼

EXPLAIN: planner's estimate only.
EXPLAIN ANALYZE: actually runs the query and reports real times.
EXPLAIN (BUFFERS, ANALYZE): + buffer hits/misses — tells you I/O vs cache.

Why is a Seq Scan faster than an Index Scan sometimes?

Show ▼

When the planner expects to return a large fraction of the table — random I/O via the index would be slower than reading sequentially.

Function used to add a B-tree index for equality + range queries?

Show ▼

CREATE INDEX ON t (col); — default is B-tree.

Index type for full-text search?

Show ▼

GIN on to_tsvector columns.

Index type for geometric / array containment?

Show ▼

GiST or GIN.

How to index JSONB key lookups?

Show ▼

CREATE INDEX ON t USING GIN (col jsonb_path_ops);

How to make a unique index that ignores NULLs?

Show ▼

Postgres treats NULLs as distinct in unique indexes by default — use partial: CREATE UNIQUE INDEX ON t (col) WHERE col IS NOT NULL;

Vacuum vs Autovacuum?

Show ▼

VACUUM: reclaim dead tuples, update stats. Autovacuum: background daemon that triggers based on dead-tuple thresholds. Tune autovacuum_vacuum_scale_factor for hot tables.

What is bloat?

Show ▼

Dead tuples + free space in a table after many UPDATE/DELETEs that VACUUM hasn't reclaimed; causes larger reads.

Tool to inspect bloat?

Show ▼

pgstattuple extension or query views like pg_stat_user_tables.

🎓 Start studying Postgresql Performance Tuning

🎮 Study Modes Available

🔄

Flashcards

Flip to reveal

🧠

Focus Mode

Spaced repetition

Multiple Choice

Test your knowledge

⌨️

Type Answer

Active recall

📚

Learn Mode

Multi-round mastery

🎯

Match Game

Memory challenge

Related Topics in Databases

📖 Learning Resources