by bob1029 · 1y ago · 0 comments
This technique is very well supported in the big commercial engines. In MSSQL's Indexed View case, the views are synchronously updated when the underlying tables are modified. This has implications at insert/update/delete time, so if you are going to be doing a lot of these you might want to do it on a read replica to avoid impact to production writes.
https://learn.microsoft.com/en-us/sql/relational-databases/v...
https://learn.microsoft.com/en-us/sql/t-sql/statements/creat...
Oracle's implementation scales horizontally and can do incremental view maintenance using commit logs:
https://oracle-base.com/articles/misc/materialized-views
But it may not even be necessary because Oracle also supports query caching both server and client side. By default you have to opt-in on the query level:
SELECT /*+ RESULT_CACHE */ .... FROM .....
but if you do then queries might not even hit the database at all, the results are cached by the drivers. The main limitation of that feature is that it's meant for read-mostly tables and cache keys are invalidated on any write to the table. So for aggregating counts in a large multi-tenant table the hit rate would be low and a materialized view is more appropriate.It's a bit unclear why the author of the article ignores triggers as not "in vogue" though. That's supported by every DB and will work fine for this use case. You do have to learn how to use these features but it can save a lot of work, especially when introducing non-consistent data sources like a Redis cache. Consistency is so valuable.
Disclosure: work for Oracle, opinions are my own (albeit in this case, presumably highly aligned).