Design a Reactive Database (Live Queries), stage 9 of 9: defend it
Defend building it into the database
Your interviewer: "This is a lot of machinery. Why not keep Postgres, add a cache, and use change data capture or LISTEN/NOTIFY to tell clients to re-fetch?"
System so far· 7 parts
Select a component to see what it is responsible for and which state it owns.
- 1Web and mobile apps → Sync servers: Subscribe and mutate
- 2Sync servers → Function runners: Run a function
- 3Function runners → Versioned store: Read at a snapshot
- 4Function runners → Committer: Writes plus read set
- 5Committer → Versioned store: Append in timestamp order
- 6Versioned store → Subscription tracker: Committed writes, in order
- 7Subscription tracker → Sync servers: These subscriptions changed
- 8Sync servers → Web and mobile apps: New results
- 9Function runners → Result cache: Reuse identical runs
- Request / response
- Asynchronous
- Server push
What you need to know
0 of 1 checks done
Change data capture (CDC) and
LISTEN/NOTIFYtell you a row changed. They don't tell you which queries that change affects. Mapping one to the other needs either read sets or hand-written rules, which is the problem this design solved.A strong defence names the properties the simpler route lacks, not just the mechanism yours has.
Check
When is "Postgres + cache + notify clients to re-fetch" the right call?