The Vertica Forum recently got a makeover! Let us know what you think by filling out this short, anonymous survey.
Please take this survey to help us learn more about how you use third party tools. Your input is greatly appreciated!

What's the best way to store calculated data in a database?

WyattKaiWyattKai Community Edition User
edited June 2021 in General Discussion

What's the cleanest way of going about this? How often should the data in the database be recalculated / at which events should the data be recalculated.

I'm currently trying to model upvotes in posts. I don't know if it's faster if I just sum the vote integers (0, 1, or -1) every single time a post is loaded, or if I just store the initial upvote count and just increment and decrement it, and only calculate the sum every once in a while


  • marcothesanemarcothesane - Select Field - Administrator

    If the table where you store the votes gets a new row each time a vote is made, consider a Live Aggregate Projection that contains SUM(vote) GROUP BY (<whatever_makes_sense>). This way, you don't need to store the sum, but can get it from a pre-aggregated data store every time you SELECT SUM(vote) FROM ... .

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file