webcu
webcu
CCConvex Community
Created by webcu on 1/28/2024 in #support-community
DB Bandwidth
Hi! First of all, thank you for creating Convex! It's a fantastic project, and I look forward to building many projects with it. 🙂 Now, the DB Bandwidth is a recurrent issue. I checked the previous questions and couldn't find the solution to my problem, but they provided some valuable hints. The situation in my case was that I was dealing with creating and manipulating dates inside my query, ex: const date = format(subDays(new Date(), 30), "yyyy-MM-dd"); and this was causing it never hit the cache, and I ended up consuming the bandwidth of the free plan 😦 I read the doc multiple times, and this section: https://docs.convex.dev/functions/query-functions#caching--reactivity was a bit misleading, at least for me, when it mentioned:
You might wonder whether you can use non-deterministic language functionality like Math.random() or Date.now(). The short answer is that Convex takes care of implementing these in a way that you don't have to think about the deterministic constraint.
You might wonder whether you can use non-deterministic language functionality like Math.random() or Date.now(). The short answer is that Convex takes care of implementing these in a way that you don't have to think about the deterministic constraint.
I assumed that Convex would take care of making deterministic, somehow :), any Date function. After checking the logs in Convex's console and the messages arriving at the websocket in the browser, I started to put together the dots and found the issue. This comment: https://discord.com/channels/1019350475847499849/1157663868324171776/1157696579109666967 was especially useful to realize that I wasn't hitting the cache because somehow my query was different each time. Another issue I had in the query was that I was doing a subquery, and in the function of a value previously calculated, I'd apply a filter or another, and if I'm not mistaken here, that wasn't allowing me to hit the cache either. I've adjusted both of those issues. Now I'm hitting the cache like Babe Ruth, and my bandwidth levels aren't going off the roof 🙂.
2 replies