MySQL 00:00:01 Find the book called Cats A librarian knows the title Cats but needs its shelf location. In our MySQL table, InnoDB stores rows in the clustered primary-key index. A separate title index pairs each title with the primary key that identifies its full row. Search the title index for Cats. The leaf gives the librarian key thirty. If the request needs a field absent from that index, follow thirty through the clustered index to reach the complete catalog row. Change the question to just title and identifier. Both are already in the secondary index. That can eliminate the second lookup. The cost of an index depends on exactly which columns the query needs back. 00:00:45 Which price does a reader see? A reader takes a consistent snapshot of the catalog. InnoDB can reconstruct the appropriate older version while later edits change the current row. An undo record preserves information needed to reverse a change for that reader. Transaction twenty raises the price from five to seven. A later transaction changes it once more. A long-running query using a suitable snapshot can still have a legitimate reason to see seven. In the example the snapshot includes transaction twenty but excludes thirty. Start at the latest row and follow the undo history until you reach seven. Purge can reclaim obsolete history when outstanding read views no longer require it. 00:01:29 A receipt before the page write When a clerk updates a row, the page in memory changes, undo preserves older information, and redo records describe changes needed for crash recovery. The database need not flush that exact table page for each individual sale. With binary logging enabled and durable commit settings, MySQL coordinates the storage engine's prepared transaction with the binary log. The latter also carries changes used for replication or point-in-time recovery. Each log serves a different reader. Assume a crash after a transaction entered the binary log but before the last in-memory steps finished. During recovery, the server reconciles prepared work with the durable log. In the illustrated case it resolves the transaction as committed. 00:02:17 Why a confirmed edit can look lost The source commits the librarian's edit. The application remembers the transaction identifier associated with that write. This becomes a concrete freshness requirement when the librarian refreshes the page. One replica has applied the edit, another has not. Route the next read to the lagging one and the old price reappears. The source still has the committed edit. Write success and immediate visibility on every replica are separate properties. Ask whether the selected replica has applied the required transaction. In our example, the wait budget is two hundred milliseconds. If it cannot catch up in time, read from the source. Charge that fallback to your capacity budget. 00:03:01 Recover an accidental deletion Imagine an accidental deletion after Wednesday's morning sales. A healthy replica promptly applies it too. Replication did exactly what was asked, which makes a synchronized copy a poor way to retrieve the previous business state. Restore an earlier full backup on a separate machine. Keep the live system and later legitimate writes intact while investigating. The recovery machine gives you a safe place to decide what was present before the mistaken transaction. Replay retained binary logs up to just before the deletion. Validate the restored rows before reconciling them with new sales. Remember the different routes through our catalog. Indexes find rows, undo supplies older views, and a tested backup plus logs can reconstruct an earlier database.