Re: Write Last, Read First

Applying the rule to NoSQL databases.

Dominik Tornow in The Write Last Read First Rule on 2025-11-06:

Once the system of record is chosen, correctness depends on performing operations in the right order.

Since the system of reference doesn’t determine existence, we can safely write to it first without committing anything. Only when we write to the system of record does the account spring into existence.

Conversely, when reading to check existence, we must consult the system of record, because reading from the system of reference tells us nothing about whether the account actually exists.

This principle—Write Last, Read First—ensures that we maintain application level consistency.

Remarkably, if the system of record provides strict serializability, like TigerBeetle, and if ordering is correctly applied, then the system as a whole preserves strict serializability, leading to a delightful developer experience.

This is one of the first things I had to learn when working with a NoSQL database, DynamoDB. For the two major projects I worked on that used Dynamo at Amazon, we'd have a main table containing the application data, and a few index tables to support alternative query use cases. DynamoDB only supports strong consistency when working with the partition and sort keys of a table — Global Secondary Indexes are only eventually consistent, and DynamoDB Transactions didn't exist yet.

To achieve strong consistency over items in the main table and their dependent index items, we'd operate as the article describes. You write index items first and finish with the write to the main table. The system as a whole remains consistent with the additional application-level logic to ignore orphaned index items (somehow the main item failed to write, so ignoring the index item maintains consistency), and the main item write is only performed once the index writes are successful. Bringing that back to the original article, you treat the main table as the system of record (TigerBeetle) and the index tables as the systems of reference (Postgres).