how do I efficiently aggregate data?
How do I aggregate data? I.e I have orders, how do I calculate the total amount through entire period? I would assume querying all records and adding up the count wouldn't be the best option?
2 Replies
If you have dataset that becomes very large. querying all record (COUNT in SQL) is not efficient even if Convex provides that.
Best workaround would be to track Metadata.
Creating a separate table and updating the records as new data comes in OR
running a schedule function (which convex supports aswell) to count the number of records per day, per hour (depends on your choice) will give you the data you need at end of cycle to get the summary.
thanks