How Google Maps Knows Traffic: Phones, Colours and ETAs
How Google Maps knows traffic: phones send anonymous speeds, roads turn green, orange or red, and ETAs mix live and past data, with the 2020 wagon hack.
10 min readTaken apart to see how it works.
PostgreSQL and SQLite errors, payments, and how everyday tech works.
A red road on your screen is built from other people's phones. Here is how that works, and what Google keeps to itself.
SQLite lets many connections read but only one write. Here is exactly when that turns into SQLITE_BUSY.
Start with one slow query, read what SQLite says about it, and fix it one index at a time.
One slow SELECT, one quick ALTER TABLE, and every query behind them waits. Here is why, and how to stop it.
SQLite can serve a busy, read-heavy site from one machine. Here are the settings, the habits, and the point where you should stop.
A twelve-part series on how a Tesla is made and how it drives itself: castings, the battery floor, wiring, the cameras, the chip, the neural networks, the data engine and the robotaxi.
A three-part series on handling money in a database: how to store amounts, a double-entry ledger in Postgres, and reconciling it against the bank.
A three-part series on building reliable backends with one database: a job queue, safe API retries and a transactional outbox.
How Google Maps knows traffic: phones send anonymous speeds, roads turn green, orange or red, and ETAs mix live and past data, with the 2020 wagon hack.
10 min readHow SQLite locking works, why you get 'database is locked' (SQLITE_BUSY) even with a busy timeout, and how WAL mode and BEGIN IMMEDIATE fix it.
13 min readLearn how SQLite indexes work. Read EXPLAIN QUERY PLAN, then fix a slow query step by step with composite, covering, partial and expression indexes.
16 min readPostgreSQL locks explained: how one slow SELECT and a quick ALTER TABLE can stop a site, how to find blockers with pg_locks, and how to migrate safely.
19 min readSQLite in production: the PRAGMA settings, WAL mode, one-writer pattern, checkpoints and Litestream backups for a busy site, and when to pick Postgres.
16 min readHow contactless payment works: the card has no battery and runs on the terminal's 13.56 MHz field, then sends a one-time code a thief cannot replay.
14 min readPostgres says duplicate key value violates unique constraint. Three different bugs print it: a race, a stale sequence, a retry. Each one has its own fix.
16 min readERROR: deadlock detected in PostgreSQL. Read the DETAIL and server log lines to find the two statements, then fix it with one lock order and a retry.
14 min read