Re:Ask HN: How Can I Make My Front End React to Database Cha...
by mysterydip on Friday April 19, 2024 @07:22AM
(#40085420)
Maybe I'm misunderstanding, but you said anything goes, so here goes:
If rerunning entire queries is the problem, can you implement a changes table (could potentially double as an audit table if desired) which on a basic level just has time and rowid. Then you poll that table for anything newer than your current timestamp. Say for a report with 1000 rows, only 2 have changed in the last second. Then you can just do a query of the big table on those exact rowids.
The benefit over having timestamp in the big table is the changes table can be kept to a minimal size. You don't need to store any more than, say, a minute's worth of changes. Anyone visiting the page for the first time or that far out of sync will poll the whole report.
If rerunning entire queries is the problem, can you implement a changes table (could potentially double as an audit table if desired) which on a basic level just has time and rowid. Then you poll that table for anything newer than your current timestamp. Say for a report with 1000 rows, only 2 have changed in the last second. Then you can just do a query of the big table on those exact rowids.
The benefit over having timestamp in the big table is the changes table can be kept to a minimal size. You don't need to store any more than, say, a minute's worth of changes. Anyone visiting the page for the first time or that far out of sync will poll the whole report.