Muhtadee Taron
Muhtadee Taron6mo ago

Need help regarding bandwidth

Hey guys, a newbie here. I made a notion clone with the help of the tutorial from Antonio and have been using it as my regular note app. But few days ago it shows that my bandwidth usage has passed the free tier limit. I don't actually know much about databases and backend stuff yet. So, can someone please enlighten me on how I can fix this thing and enable my project while keeping the usage within the limit? Attaching a picture for reference.
No description
13 Replies
pensono
pensono6mo ago
I've run into the same problem- The answer here is probably to add some indexes/etc in the right place. Is there any way to see the amount of bandwidth used by a particular db call? Perhaps this should live in the logs or in spans somewhere or the custom query UI in the dashboard could show this value
ballingt
ballingt6mo ago
Could you share the rest of that page? There should be all kinds of breakdowns so you can see which functions.
pensono
pensono6mo ago
I can break down the usage by function, but I only see a total rather than an amount used by a single invocation
ballingt
ballingt6mo ago
@pensono that's still useful information, which functions are contributing most? message received though that it would be nice to see this information in the dashboard. This information is in log streams https://docs.convex.dev/production/integrations/log-streams/ but that's a paid feature great idea to show it in the custom query UI, so you can get a feel for this live
pensono
pensono6mo ago
Ah nice, yep that's exactly the sort of thing I was looking for.
ballingt
ballingt6mo ago
@pensono what functions do you see taking up most of the bandwidth, and are they search? looking around online at code that he thinks is from Antonio a colleague found a search function that might always be subscribed but that's very tenous, what is it for you?
pensono
pensono6mo ago
Oh, I can see which function is the problem in my project pretty clearly. I'll check back if I need help. OP's project is different
ballingt
ballingt6mo ago
Ah got it, thanks. @Muhtadee Taron, curious what function you see here. classic thread mixup
Muhtadee Taron
Muhtadee TaronOP6mo ago
Yeah @ballingt, it's the search function that is taking up most of the bandwidth. Not actually sure how I should fix this as I'm still learning stuff. I'm attaching more info here.
No description
lee
lee6mo ago
Could you share your source code? I've seen a version of notion-clone and it looks like the search function subscribes to all documents and it's always rendered so you are downloading every version of every document. It would be more efficient to put the useQuery(api.documents.getSearch) in a react component that only renders when the search bar is focused
Muhtadee Taron
Muhtadee TaronOP6mo ago
Sure here's the source code @lee, https://github.com/muhtadeet/kami
GitHub
GitHub - muhtadeet/kami: Not your average note app
Not your average note app. Contribute to muhtadeet/kami development by creating an account on GitHub.
lee
lee6mo ago
yep it looks like the search query renders on every page, even if the search box isn't selected. you could try moving this line down https://github.com/muhtadeet/kami/blob/bb0cb9bdb5c20f08066ea82c4a628ab846bc937b/components/search-command.tsx#L23 and changing it to
const documents = useQuery(api.documents.getSearch, isOpen ? {} : "skip");
const documents = useQuery(api.documents.getSearch, isOpen ? {} : "skip");
which will make the search query only subscribe to all documents if the search bar is open.
GitHub
kami/components/search-command.tsx at bb0cb9bdb5c20f08066ea82c4a628...
Not your average note app. Contribute to muhtadeet/kami development by creating an account on GitHub.
Muhtadee Taron
Muhtadee TaronOP6mo ago
Great! I understand now what we did here. Thanks a lot! @lee One last thing, can you please tell me how I can resume my project now?

Did you find this page helpful?