4 ms·
Thanks a ton for the help, I will take a look into what we might be able to do in terms of adding a materialized aggregate view!
by dbnewbie 7y ago
Thanks a ton for the help, I will take a look into what we might be able to do in terms of adding a materialized aggregate view!
- gigatexal 7y agoYou’ll get the most benefit from pre-aggregating not for a specific query but in a general way. Sum orders group by user in a view and then use triggers to update that view. That way to get the orders for a given user it’s a simple lookup and all the calculation is done. And this way you can build up meta reports from these general aggregates.
- dbnewbie 7y agoOk awesome, and thanks again!
- gigatexal 7y agoJust to be super clear don’t use the triggers to rebuild the view every time but merely to add one to the sum’d account when a row matches — I wasn’t sure I made that clear. Good luck! And do put up a blog post or something if it works out
- dbnewbie 7y agoOK that makes sense, and I’ll do a bit of reading on materialized view functionality before actually implementing anything.
- gigatexal 7y agoI have a link somewhere I’ll find it
- gigatexal 7y agoAgain not my idea. It was suggested to me in response to the very problem you’re having. I’m just so happy to have it as an idea that I didn’t want to keep it to myself. Here’s the link. https://hashrocket.com/blog/posts/materialized-view-strategies-using-postgresql https://hashrocket.com/blog/posts/materialized-view-strategi...