When data was true and when the desk knew it
A corrected trade leaves two right answers for one moment: what the position was and what the desk knew. A synthetic example shows what a table must keep.
At 16:30 the limit report showed the desk 10 MW over. The next morning the trade behind it was corrected, and today's database says the desk was never over at all. A review of what the trader did at 16:45 has to judge it by one of those numbers. A table that keeps only the latest version of each trade can supply only the second.
“What was the position?” and “what did the desk know?” are different questions with different correct answers. Each filters on a different time, and a system can answer both on purpose only if its rows record both.
Synthetic example
The desk, the trades, the limit and the times in this piece are synthetic. They were built to show the mechanism and come from no firm.
§1One correction, three times
The desk has a 100 MW limit on its net position. On day 1 it buys 60 MW at 08:05 and books a second purchase at 09:10 as 50 MW. The limit report is run from a reporting store that loads from the trade system, and at 16:30 it shows 110 MW, which is 10 MW over. At 16:45 the trader sells 10 MW, and the trade system shows the desk back at 100 MW.
At 08:40 on day 2 the second purchase is corrected: it was 30 MW from the start. Corrections like this are routine. They are entered after the fact with an effective date in the past, often after reports have gone out. Every row in this desk's ledger carries three times, and for the correction they are a long way apart.
- Effective time is when the fact applies. The corrected quantity applies from 09:10 on day 1, when the trade was done.
- Arrival time is when the fact reached the trade system, the earliest moment the records can show the desk had it. For the correction that is 08:40 on day 2, 23 hours 30 minutes after it took effect.
- Processing time is when a downstream store loaded the fact. The reporting store took in the correction at 12:00 on day 2, 3 hours 20 minutes after it arrived.
| Fact | MW | Effective | Arrived | Processed |
|---|---|---|---|---|
| Buy | +60 | Day 1 08:05 | Day 1 08:05 | Day 1 12:00 |
| Buy, as first booked | +50 | Day 1 09:10 | Day 1 09:10 | Day 1 12:00 |
| Sell | −10 | Day 1 16:45 | Day 1 16:45 | Day 1 18:00 |
| Buy, corrected | +30 | Day 1 09:10 | Day 2 08:40 | Day 2 12:00 |
| Limit | 100 | Day 1 00:00 | Day 1 00:00 | Day 1 06:00 |
| Limit, raised | 120 | Day 2 00:00 | Day 2 10:00 | Day 2 12:00 |
§2Both answers are correct
Ask on day 3 what the position was at 16:30 on day 1, and the query filters on effective time alone: every trade effective by 16:30, in its newest version. The answer is 90 MW, which is 10 MW under the limit. That is what the desk actually held at 16:30.
Ask what the desk knew at 16:30 and the query adds a second filter: only versions that had arrived by 16:30. The correction had not, so the answer is 110 MW, 10 MW over. The two answers differ by 20 MW and neither is an error.
The same pair exists after the sale. At 17:00 the desk knew its position as 100 MW, back on its limit. The corrected ledger says 80 MW.
§3The sale is judged by what the desk knew
A review asks whether the 16:45 sale was a sound decision. On the latest data it looks unnecessary: a desk 10 MW under its limit sold another 10 MW. On what the desk knew, a trader shown a 10 MW excess sold exactly 10 MW. The correction that makes the sale look unnecessary arrived the next morning, and judging the decision with it is hindsight.
Reference data leaks into a review the same way. The limit was raised to 120 MW for day 2, in a row entered at 10:00 that day. A review query that reads the newest limit row sets the report's 110 MW against 120 MW and finds 10 MW of headroom. The limit that applied at 16:30 on day 1 was 100 MW.
The 120 MW row takes effect on day 2 and arrived on day 2, so here either cut excludes it. A limit entered in advance for a later date would pass the arrival cut. A fair review therefore cuts on both times: effective by the moment of the decision and arrived by it.
§4A rerun on latest data doesn't reproduce the report
Replay is the same query run later. Rerun “position at 16:30 on day 1” from the reporting store at 14:00 on day 2 and it returns 90 MW, 20 MW away from the report issued the afternoon before. A report rerun later from current data can fail to match the copy originally issued in just this way, and a team then spends time explaining the difference.
Pin the cut to effective by 16:30 and arrived by 16:30, and the trade ledger returns 110 MW whenever it is asked, from 16:30 on day 1 to the review at 09:00 on day 3. The time of the rerun no longer enters the query, so a row that arrives after 16:30 can't change the result.
That 110 MW equals the issued report because, at 16:30, the store had loaded every row that had arrived. Half an hour later it had not. At 17:00 the trade system showed 100 MW and the store still showed 110 MW, with the sale waiting for the 18:00 load. A report run from a store is reproduced by pinning that store's processing time. What the desk knew is reproduced by pinning arrival time.
Reconciliation needs the third time. At 09:30 on day 2 the trade system answers 90 MW for the 16:30 position and the reporting store answers 110 MW. The 20 MW break is one row: the correction arrived at 08:40 and the store did not load it until 12:00. By 14:00 both say 90 MW.
A reconciliation that sees each row's arrival time can attribute the break to a row that reached the trade system after the store's last load. One that sees only two totals has a 20 MW difference to investigate.
§5What the table has to record
Trade and reporting tables often overwrite a row in place, or keep a single “last updated” time. After the correction such a table holds the second purchase at 30 MW, last updated at 08:40 on day 2. Its only answer for the 16:30 position is 90 MW. Filter it on “last updated” by 16:30 as well and the corrected purchase drops out whole, leaving 60 MW, which is neither what the position was nor what the desk knew. The 50 MW version is gone, and with it the only route back to 110 MW.
Three things have to be recorded for both questions to stay answerable.
- Every version of a fact is kept as its own row. A correction adds a row and removes nothing.
- Each row carries its effective time and its arrival time. The arrival time is the source system's, copied downstream unchanged.
- Each store adds its own processing time. Each report records the cuts it was run with: the effective time and the arrival time or, for a report run from a store, that store's processing time.
The SQL standard has had most of this shape since SQL:2011. As Kulkarni and Michels' account of its temporal features sets out, it lets one table carry an application-time period, set by the user, and a system-time period, assigned by the database. System time is the clock of whichever database holds the table. In a trade system it corresponds to arrival time. In a reporting store it is processing time, so a store that relies on its own versioning can say what it held at 16:30 and still not what the desk knew.
Apache Flink's documentation draws a similar line between event time, when an event occurred at its producer, and processing time, the clock of the machine handling it. By that definition the event for a correction is its entry in the trade system, so its event time is arrival time here, not effective time. Each vocabulary names two times. A corrected trade has three, and the table design has to say which is which.
Keeping every version takes more storage than keeping the latest. No query has a safe default either: each one states its effective cut and its arrival cut, or says that it wants the latest of both. And arrival time is the trade system's. When a person learned the fact is a separate time, and a trade ledger doesn't hold it.
A table that records when each fact was true and when it arrived answers “what was the position?” with 90 MW and “what did the desk know?” with 110 MW. It can also show the row that separates them. A table that keeps only the latest version has 90 MW as its only answer, whichever question is asked, and for the second question that answer is wrong.
