Skip to content

Act III — The Wi-Fi Era#

Month 2. The hostel is famous, the guest directory has thousands of rows, and Maya is debugging the morning dashboard from the harbour café over 15 ms Wi-Fi.

Month 2. The hostel is famous, the guest directory has thousands of rows, and Maya is debugging the morning dashboard from the harbour café over 15 ms Wi-Fi.

Maya: Every extra round trip feels like waiting for a ferry. And Management wants city revenue digests AND a region map by breakfast!

Ferris: Good. Latency makes bad queries honest. Time for keyset cursors, 1-RTT pipelines, SQL analytics, and recursive trees.

Month 2 to Month 3. Everything worked on ten rows on localhost. Now real scale and real network latency show up. In Act III you'll replace slow OFFSET pagination with index-backed keyset cursors, collapse whole transactions into a single network round trip, compute subtotals and top-N rankings inside PostgreSQL, and traverse hierarchical region trees with typed recursive CTEs.

This act's shifts#

Ch. Shift What you'll get Superpowers
9 The Endless Guest List Page 10,000 is as fast as page 1, and the planner's index choice is asserted in tests. pg.tuple_() keyset pagination explain()
10 Harbour Wi-Fi BEGIN, two inserts and COMMIT in a single round trip, even over terrible Wi-Fi. pipeline() currval() pg.prepare()
11 The Morning Revenue Digest Subtotals, grand totals and top-N per group without pulling a single row into Python. FILTER (WHERE …) ROLLUP GROUPING()
12 Mapping the Empire Walk a whole tree in one typed recursive query, with cycle protection built in. Table.alias() recursive_cte() SEARCH DEPTH FIRST