PLAIN/TEXT — ISSUE 177/456 COMPUTER SCIENCE · FOUNDATION / DATA / CHANGE STREAMS · ~4 MIN READING DATE: 2027-03-27 ARCHIVE: https://plaintext.click/newsletter/ SUBJECT: How a search copy learns that a record changed How a search copy learns that a record changed ============================================== / START HERE A shop’s checkout and product search can keep separate copies of stock information. A database is a store of records that programs can search and update. Change-data capture, or CDC, is a method for extracting database changes and sending them to other systems. Instead of repeatedly copying every product, a receiving system can follow which records were added, changed or removed. / WHY NOW The search copy needs a way to learn about a stock edit without asking the checkout database to rebuild the whole catalogue. Following a change stream narrows the work, but introduces progress and replay questions. / THE IDEA A log-based CDC system reads the source database’s recorded changes and decodes them into record-level messages. The source can keep its normal current tables; the CDC stream describes what happened to those tables. A receiving program applies those messages to its own representation, such as a search catalogue. The receiver records how far it has processed the stream. On restart, that position lets it resume instead of starting from the beginning. It still needs a safe relationship between applying an update and advancing its position: a crash between those steps can cause a change to be delivered again. / THE FORMAL IDEA copy at position n = apply(copy at n − 1, change n) - n labels an ordered change position in this simplified single-stream example. apply means perform the described insert, update or deletion on the receiving copy. - The position tracks progress, not wall-clock freshness. A row’s identifying key tells the receiver which product to change; the message’s contents determine the new representation. / RUN THE TINY EXAMPLE Change one thing. Predict what happens. The search copy has product 7 with stock 10 and has processed through change 40. Change 41 sets product 7 stock to 8. Applying it gives stock 8 and progress 41. Change the source input again: change 42 sets the stock to 6. After applying 42, the copy shows 6. Until 42 is applied, it can still show 8 despite the source already containing 6. The copy’s lag is explicit: its answer is current through a particular processed position. Reapplying change 41 immediately leaves stock at 8 if handled as a replacement, whereas misinterpreting it as subtract two would produce 6 after a duplicate delivery. A late repeat of 41 after 42 still needs a position check, or it could wrongly restore 8. Message meaning and ordering both matter. / SO WHAT? An initial complete copy must line up with the change stream, or edits during that copy can be lost or counted twice. The design needs both a starting snapshot and a continuous handover, not merely a background listener. / ONE CAVEAT CDC often describes storage changes, not business intent: a changed number may not distinguish a sale from a correction. Ordering, duplicates, schema changes and deletions require deliberate handling. Retaining changes for a stalled receiver also consumes source storage. / KEEP THIS A change stream replaces repeated full copying with ordered incremental work, but the receiver’s processed position determines how current its answer can be. / SOURCE TRAIL [1] PostgreSQL — Logical decoding, streams and replay considerations https://www.postgresql.org/docs/18/logicaldecoding-explanation.html NEXT: Why the final temperature is not always the midpoint --- HARD IDEAS. PLAIN TEXT. You are receiving this because you asked for one clear computer-science or physics idea each day. Unsubscribe: https://plaintext.click/unsubscribe View in browser: https://plaintext.click/newsletter/2027/03/2027-03-27-change-data-capture.html From: Plain/Text / Brickston Consulting · 30 N Gould St Ste N, Sheridan, WY 82801 US · knowledge@plaintext.click