oscklmO
Convex Community3y ago
9 replies
oscklm

Keeping track of stats, docs count etc with Convex?

Heeey 👋

So i've grown quite curious over the last couple of days on how to count and keep track of stats. Is there a suggested way to count tables total docs and such with Convex?

Scenario
I go ahead and create a new post in our admin dashboard, and the newly created post then gets reflected on the front dashboard page which shows various stats about our platform, total videos, gross revenue, total users etc. all of these coming from various apis.

Idea 1: Real-Time Updates
Some method to increment or decrement some kind of counter in a statistics table, then each time an item gets created or deleted we find its stat and increment/decrement it. Would this be a viable approach? I have some bad feelings about this 🫣

Idea 2: Periodic Updates
Some recurring scheduled task that runs every 15-30 minutes, calculating the total documents in several tables. However, I'm uncertain about how to do this, and also keep it both performant and usage-efficient in terms of cost.

I would love to start a discussion about this topic and explore the different potential solutions. Any suggestions or advice are welcomed!
Was this page helpful?