00 /What You Will Learn
By the end you will be able to
- Read an
EXPLAIN (ANALYZE, BUFFERS)plan for bothOFFSETand keyset queries. - Explain why
OFFSET 50000 LIMIT 20scans 50,020 rows and throws away 50,000 of them. - Build a composite B-tree index on
(created_at DESC, id DESC)for instant keyset seeks. - Demonstrate the duplicate item drift trap when concurrent inserts happen between pages.
- Implement bidirectional keyset traversal (Next and Previous page) without session state.
Before you start
Finish Lab 04 (SQL Basics with PostgreSQL) and Lab 15 (Database Indexing) first. You should know what an Index Scan and B-tree are. Docker Desktop must be running.