amppA
Convex Community2w ago
6 replies
ampp

Component counting bandwidth for each access within a function!

🪲Bug Report
I'm not sure this is but or known situation, i was not able to find any mention of it.
This is a serious consumer of DB bandwidth if not monitored.
And width how my codebase is designed very difficult to not do this.
With native ctx.db you can just call .query() for the same data over and over without it counting against you.

I tested this on the rateLimiter.
I insured only one row was in the component removing any chance of it accessing a different record.

at first i was doing, all within a query.
    const result = await rateLimiter.check(ctx, args.type, { key: args.uId,})
    const result2 = await rateLimiter.getValue(ctx, args.type, { key: args.uId, })

I noticed 2 document accesses when i expected one
then i tried
    const result = await rateLimiter.getValue(ctx, args.type, { key: args.uId,})
    const result2 = await rateLimiter.getValue(ctx, args.type, { key: args.uId, })

and the same 2 document access
260 bytes x2 520.
if i remove one i get 260 bytes etc.

Now id have to implement check() to solve this particular inefficiency.

Is this on the list of optimizations assuming its a expected situation?
I assume writing may have the same ramifications?
Was this page helpful?