Running total (cumulative sum) by date

I guess the most performant way is to precalculate on update then? SQL-speak, there should be “tables” that keep running total for each granularity, e.g. total_in_month:

User Month Count Total
John 2019-01 3 3
John 2019-02 2 5 (3+2)
Mary 2019-01 2 2

Will there be any (performance) advantage of putting this kind of data in Dgraph as opposed to SQL?

Regarding GroupBy for date: Thanks for clearing it up!

All the while I thought @index(day) means “to index down to day granularity”, which means, I can query/group by year and month as well such as @filter(gt(date, “1980”)).

1 Like