by code_biologist · 6y ago · 0 comments
Two things that would help:
1. Getting Incremental View Maintenance (IVM) [1] into Postgres. It looks like work is beginning on this but it's been 7+ years coming. If there are any Postgres devs looking at this, I'm cheering for you!
2. There's a commercial group doing an implementation of this, Materialize [2], but they don't have any publicly released product yet. I mention it because their interview on Data Engineering Podcast is really good [3] and I really like their focus on correctness by working from replication logs.
[1] https://wiki.postgresql.org/wiki/Incremental_View_Maintenanc...
[3] https://www.dataengineeringpodcast.com/materialize-streaming...
e.g. insert into rollup_clicks_hourly select hour, count(*) clicks from clicks where created_at >= ? and created_at < ? group by 1
Then from a reporting perspective, users/dashboards/etc read from the highest relevant table that meets their criteria.Could you recommend any classic old-school books about data warehousing that you'vre read that teach more such techniques?
Thank you!
https://www.amazon.com/dp/product/1118530802 and possibly https://www.amazon.com/dp/0764567578/
[1] https://hashrocket.com/blog/posts/materialized-view-strategi...
There are other initiatives for plugging it on existing RDBMSs, like Noria [1] for MySQL. It allows for subscribing to changes; and also for lazy evaluation of the materializing view rows, keeping them in cache for later.
In PG you can make a lot of queries run straight from one index if you tailor an index to a query, since you can index your own plpgsql functions.
The syntactical sugar does have advantages, but comes at a cost of flexibility - if you need more control over the update process or modification of the data than a full refresh, then you should just use a table (create table whatever as select * from ...).
Can anybody here speak to that choice?
Part of the power of OP's technique is that it looks exactly like a standard Django/Rails data model with a tiny sprinkle of magic -- no surprises. It's surprising for a Django programmer to hear "all periodic tasks are handled via celery, except these table refreshes" or "signals are responsible all work in response to model changes, except these triggers".
Obviously in some cases you need a trigger for correctness, but in general I try to stick to the conventions of the ecosystem.
I personally don't like having my cron distributed in different areas. All my crons are in one place/system like easycron.com or setcronjob.com or whenever. Performance is not a consideration when deciding to run the job directly from the DB or the App.
I answered the question sentence directly, but maybe that's not what you were asking?