Re:How PostgreSQL aggregation works and how it inspired our ...
by nextaccountic on Friday August 06, 2021 @01:47AM
(#28083734)
Hey, that seems very cool!
I saw it is written in Python. Does the Python code run only when creating the sql query? Am I supposed to add the generated sql code to git?
Re:How PostgreSQL aggregation works and how it inspired our ...
by paulddraper on Friday August 06, 2021 @07:15AM
(#28085580)
Correct. The Python code generates the triggers and functions to keep the rollup table up-to-date.
Add the SQL DDL to whatever migration control system you use.
I found this to be a very common need, so I created denorm [1] for doing this in vanilla PostgreSQL. (It also does incrementally updated joins as well.)
It's a real help to instant aggregation results for large data sets.
(I expect the performance of a native implementation like Timescale to be superior. Unfortunately, I use managed database services, like RDS.)
[1] https://github.com/rivethealth/denorm