by adamzochowski · 3y ago · 0 comments
They update view data (counts and group by and sums) as the source table data changes. But not by rerunning the view, but smartly updating its contents based on the change that happened.
There are tons of limits in these views, as they have to provide stable results.
See ms sql documentation on limits of streamed/indexes sql views https://learn.microsoft.com/en-us/sql/relational-databases/v...
If my RBDMS adds materialized views, I want it to help me with it lol
The easiest example I can think of is the direction of the flow of data. Postgres, for example, works from "top to bottom", where you start with the result node which runs the node underneath it and so on. Each node continues requesting information from the node underneath it until it returns Null, meaning it finished. This works very well with a snapshot of the data- but if you want to maintain a high throughput with a constant stream of changes, you're going to want to work in the opposite direction- this would mean either overhauling the very way Postgres works, or adding a completely different engine into Postgres.
Seems the author made a lot of assumptions without a lot of research.
For one example, I would strongly doubt that count(*) without a where clause isn’t already highly optimized.
It's actually not well optimized in PostgreSQL because of MVCC. See https://wiki.postgresql.org/wiki/Slow_Counting
TL;DR:
The fact that multiple transactions can see different
states of the data means that there can be no
straightforward way for "COUNT(*)" to summarize data across
the whole table. PostgreSQL must walk through all rows to
determine visibility.Also worth noting Delta Live Tables, another very popular streaming SQL implementation. https://www.databricks.com/product/delta-live-tables