Usage above free plan limits
So I got this warning today that my usage is above the free plan limits. The only usage I see that is past the limit is Database bandwidth.
How can I decrease the usage for this to avoid the service interruption? Is that even possible?

4 Replies

high bandwidth usage is almost always not using indexes(.withIndex) properly which usually means full table reads because of .filter() usage.
There is one problem is if you need counting, there's currently no way of counting without fetching everything
In an ideal world the preliminary query object resulting from withIndex() should have the count() method and that would materialize just the count from the index without fetching the documents
It should be very much possible
Also while we're at it, I think we could have a skip(x) method too, that would skip records directly at indexing stage before starting to actually materialize documents and that would allow for a less efficient, but seekable paging techique
In that technique, the frontend can query how many records, do a state with current page and total records, do the skip = currentPage * pageSize and take = pageSize, numPages = (totalRecords/pageSize) + (totalRecords % pageSize === 0 ? 0 : 1) and display those 1, 2, 3, 4... buttons on screen so that the user can manually seek a specific page
the most efficient way to count right now is to track it separately, the best way is using the shardedCounter component with convex-helpers triggers to watch for inserts/deletes etc and keep track
large selects will all eventually run into a per query bw limit or a row count limit.