CheQita
CheQita6mo ago

High usage when reactively querying large objects

In 5 days of me developing a few hours a day I managed to blow up the usage of db bandwidth and I figured reactivity was not a good idea on all places for my application. I have now figured out ways to massivly lower my usage with custom query hooks. However it feels like Im getting ratelimited now that my usage has gone over the limit. Would be really nice If you guys could help me out with it. Im still developing and testing out and should not be needed to upgrade to PRO yet.
12 Replies
jamwt
jamwt6mo ago
are you using indexes pervasively? generally speaking, if you're just developing something yourself, and you run out of free db bandwidth, it's one of two issues (1) creating some kind of infinite reloading loop (2) not using indexes
jamwt
jamwt6mo ago
Queries that scale
As your app grows from tens to hundreds to thousands of users, there are some techniques that will keep your database queries snappy and efficient. I’...
jamwt
jamwt6mo ago
also, if you drill into your usage detail on the dashboard, you should be able to see what function(s) are contributing to find any hot spots
CheQita
CheQitaOP6mo ago
Im using convex ents. I have reviewed my usage and I know the reason of it. I have a a Ent called "Hub" that contains alooot of data. 20k chars of stringified json, embeddings data and more. I have a a component that queries a list of these Ents selecting all data and it was reactive. Therefore everytime I update data in any of these hubs, this component refetches all this data. Now like I said I have drasticly lowered the usage by removing the reactivity in that component. Along with some other modifications. Another solution would be to only fetch some of the data of the hubs, only the data that the component needs. Right now I guess I select all data and not sure how to only select some fields.
ian
ian6mo ago
yeah right now you can only fetch full documents, so to reduce it you could break it up into related objects you only fetch when you need them. e.g. I store embeddings in a different table than my regular data, and when I do vector search, I use the _id returned to find the regular data, not read the embeddings table. like https://docs.convex.dev/search/vector-search#using-a-separate-table-to-store-vectors
Vector Search | Convex Developer Hub
Run vector search queries on embeddings
ian
ian6mo ago
You might consider also paginating - if you only grab 10 hubs at a time, then when one updates you'd only be re-fetching 10 hubs (that page), instead of the whole list
Matt Luo
Matt Luo6mo ago
When we use full text search (as opposed to vector search), should we likewise use a separate table in order to use less database bandwidth?
ian
ian6mo ago
I don’t think so, vector embeddings are special in that a short sentence can turn into 16 kB of numbers Also, text search already returns the full document. We’ll likely introduce this same indirection (returning the _id instead of full document) in the future so you can only load related documents but it seems less likely for text search use cases since the search corpus is also what you likely want to retrieve. Embeddings aren’t too useful to pass back to a client
CheQita
CheQitaOP6mo ago
Thanks thats a good idea Is there a way for me to avoid getting ratelimited with my blown up usage without upgrading?
ian
ian6mo ago
I didn't think we rate limit - just stop you if you go over after some grace period, but lmk if you see that. And if it was just one day of blowing up we may even forgive that. It would reset at the end of the month otherwise. Sorry you ran into that
CheQita
CheQitaOP5mo ago
Oh okay thanks! My project just got disabled for going over the limit now. Any possibility to help me with this?
ian
ian5mo ago
I would look into making your app more efficient if you want to run it on the free tier. You should have gotten warnings about approaching the limits, let us know if those didn't get to you. Upgrading until you have optimized it (with indexes, smaller objects, smaller pages, and other advice in the linked articles) is probably your best bet.

Did you find this page helpful?