3 ms·
Another approach could be to create the materialized view and then use some sort of event system say the pg_notify subsystem to capture an event and then increm
by gigatexal 7y ago
Another approach could be to create the materialized view and then use some sort of event system say the pg_notify subsystem to capture an event and then increment some aggregation -- this would eliminate the need for scheduled view refreshes and keep the view almost real-time and quick.
- udfalkso 7y agoThis might be best done using triggers. I've had good experiences with the Hair Trigger gem for managing these in rails.
- gigatexal 7y agoTrigger would work. But going the pg_notify approach could allow for asynchronous updating whereas the trigger approach could slow writes.
- swanson 7y agoYou could do something similar with built-in ActiveRecord callbacks as well.
- erik_seaberg 7y agoReal-time means latency is predictably within some deadline. But the system he describes is returning wrong answers quickly rather than invalidating stale cache hits and recomputing right answers too slowly.