Courses
SQL Advanced: Queries That Hold Up Under Load
Final Check: SQL Advanced
Fifteen scenario questions across the whole course. If you get twelve or more right, you can read a plan, choose an index, change a live table and prove a restore.
Course content
Join this Course
Sign in to save your progress.
-
Reading Plans
-
EXPLAIN ANALYZE: Reading a Plan Line by Line
-
Statistics, ANALYZE and Why the Planner Guesses Wrong
-
-
-
Indexes That Earn Their Cost
-
B-tree, Partial and Expression Indexes
-
GIN, GiST and BRIN: When a B-tree Is the Wrong Tool
-
-
-
Concurrency
-
MVCC, VACUUM and Table Bloat
-
Locks, SELECT FOR UPDATE and Deadlocks
-
-
-
Advanced Query Shapes
-
Recursive CTEs and Hierarchies
-
JSONB: Query Semi-Structured Data Without Regretting It
-
-
-
Running It in Production
-
Partitioning Large Tables
-
Changing a Live Table Without Locking It
-
Backup, Restore and Proving the Restore Works
-
-
- Final Check: SQL Advanced
1.
EXPLAIN ANALYZE shows Sort Method: external merge Disk: 752kB on a slow report. What does it mean, and what is a reasonable first try?
2.
Plan A has a total cost of 442 and plan B has a total cost of 90 for the same query. What can you say?
3.
Products have a tags array, and the question is which rows contain the tag gift. A B-tree index on tags is not used. Which index fits?
4.
A 500 GB log table is only ever appended to, and queries read one day at a time. Which index is small enough to keep and still useful?
5.
A customer may have many closed carts but only one open cart. Which design enforces that in the database?
6.
You run CREATE INDEX CONCURRENTLY inside a migration tool that wraps every step in BEGIN. What happens, and what do you do?
7.
CREATE UNIQUE INDEX CONCURRENTLY fails on a duplicate value. What is left behind, and what do you do?
8.
CREATE EXTENSION pg_stat_statements works, but SELECT from the view fails with a message about shared_preload_libraries. What is missing?
9.
An index shows idx_scan = 0 in pg_stat_user_indexes. Which is a good reason not to drop it?
10.
Two workers pick jobs with SELECT ... FOR UPDATE SKIP LOCKED. One worker crashes before it finishes. What happens to its jobs?
11.
What does an UPDATE do to a row in PostgreSQL, and when is the old version removed?
It changes the row in place, and the old value is gone at once.
It deletes the row and inserts it again after the next checkpoint.
It writes the new version to a separate undo file.
It writes a new row version and marks the old one as replaced. VACUUM removes the old version when no transaction can see it.
12.
A table is much bigger than its live data. pg_stat_activity shows a session that has been idle in transaction for two days. What do you do?
13.
You switch a GIN index from the default class to jsonb_path_ops to save space, and a query WHERE payload -> 'tags' ? 'vip' becomes a sequential scan. Why?
14.
A new column needs a different value in every row of a very big table, and must end up NOT NULL. Which order avoids a long lock?
15.
A restore on a new server fails because roles that own the objects do not exist. Why did the dump not carry them?
About
Fifteen scenario questions across the whole course. If you get twelve or more right, you can read a plan, choose an index, change a live table and prove a restore.
- Duration
- 15 min
- Last update
- 09/26/2026
Was this helpful?
0
0
Comments (0)
Sign in to commentNo comments yet.