widi
widi3mo ago

Frequently updated query: how to make it more efficient

Do I understand it correct that when I have a query that gets 100 rows and then I update only one of the row, the query gets called again after the single row update to refetch all 100 rows? Background: I'm creating a chat app where it is very active, typing indicators, lots of chat bubbles sent at the same time or in quick succession. If I show the latest 100+ chat bubbles (1 bubble = 1 row) to a user, does it mean the query gets called repeatedly over and over again every time a user sends a message? because I tested it, and it basically ate through all the bandwidth in my free tier after a few days of intense chatting (real human interaction though, not even stress testing it) I added index but it only helps a little bit.
2 Replies
Convex Bot
Convex Bot3mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
erquhart
erquhart2mo ago
That is basically accurate, yes. There may be optimizations possible depending on specifics, but the one thing that stands out is your mention of adding an index - you pretty much want to only use indexed queries to limit scanning as much as possible so the queries are light. I know this post is old but if you're still trying to solve this I'm happy to help.

Did you find this page helpful?