Postgres Flashcards

(26 cards)

1
Q

What does wait_event_type = Lock usually indicate?

A

Sessions are blocked by other transactions.

DBA action: identify blockers and kill idle-in-transaction sessions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does wait_event_type = IO mean?

A

Sessions are waiting on storage operations.

DBA action: determine read vs write vs WAL pressure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does wait_event_type = NULL mean?

A

The session is actively running on CPU.

DBA action: inspect query logic and execution plans.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the difference between blocking and a deadlock?

A

Blocking resolves when one transaction finishes.
A deadlock is a circular dependency and Postgres kills one transaction automatically.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the most dangerous pg_stat_activity state?

A

idle in transaction.
It holds locks, blocks vacuum, and causes cascading failures.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are all of the pg_stat_activity states?

A

Lock
IO
LWLock (Lightweight Lock)
Client
Timeout
Activity
CPU (NULL wait_event_type)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does rising commit latency usually indicate?

A

WAL or write-path pressure.

DBA action: check WAL waits and write-heavy workloads.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does IO + WALWrite / WALSync indicate?

A

Commits are waiting on WAL flush.

DBA action: throttle write bursts, break large transactions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does IO + DataFileRead usually mean?

A

Read amplification from bad plans, bloat, or cold cache.

DBA action: inspect top queries and their plans.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does a rising checkpoints_req counter mean?

A

Forced checkpoints due to WAL pressure.

DBA action: increase max_wal_size and reduce write bursts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does checkpoint_completion_target control?

A

How evenly dirty pages are flushed between checkpoints.
Higher values smooth IO and reduce spikes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does VACUUM actually do?

A

Removes dead tuples and marks space reusable.
It does not shrink tables or compact data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is bloat?

A

Extra space caused by dead tuples or unused pages.
Leads to increased IO and cache inefficiency.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is fragmentation?

A

Live data spread across many pages, reducing locality.
Causes gradual IO creep even with healthy vacuum.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Why can IO increase even when vacuum is running?

A

Vacuum cleans tuples but does not compact data.
Fragmentation causes more pages per query.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What blocks vacuum from removing dead tuples?

A

Long-running transactions, especially idle-in-transaction sessions.

17
Q

What does high shared_blks_read mean?

A

Blocks were read from storage, not cache.
Repeated high reads indicate IO amplification.

18
Q

What does high shared_blks_hit mean?

A

Data was served from memory cache.
This is fast and healthy.

19
Q

When do you run EXPLAIN (ANALYZE, BUFFERS)?

A

When a query dominates latency or IO.
It confirms plan behavior and read/write cost.

20
Q

What does “plan regression” mean?

A

Same query, different execution strategy, much more work.
Often caused by stale stats or data skew.

21
Q

What is the safest first fix for a suspected plan regression?

A

Run ANALYZE.
It’s fast, safe, and often resolves the issue.

22
Q

Do Aurora readers guarantee zero-lag reads?

A

No. Replication lag still exists.
Route read-after-write traffic to the writer.

23
Q

Does failover fix performance problems?

A

No. Failover is for recovery, not tuning.
Bad plans and bloat survive failover.

24
Q

What is Performance Insights best used for?

A

Fast incident orientation: who is slow and why.
DB Load + wait types guide next steps.

25
26