There is the famous saying

> There are only two hard things in Computer Science: cache invalidation and naming things.

Maintaining precomputed agg results falls under the first, so use it only after you exhausted all other (acceptable) options.

If you only have ~20k records you can probably get away with calculating aggregations on the fly with some query optimization for a while longer. This is, after all, what RDBMSs do best.

Written by

Full Stack Developer, Team Leader, Independent. More from me at https://hakibenita.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store