magicseth
magicseth10mo ago

Unexpected Database Bandwidth Usage

Howdy team, I've got a query that is consuming A LOT of bandwidth. It's a pretty simple query, and I call other functions equivalently frequently without the huge bandwidth cost.
const shrimpWorth = v.object({
url: v.string(),
count: v.number(),
userId: v.id("users"),
});

export const getShrimpCountForResource = queryWithUser(({ db, user }, { url }) => {
return db
.query("shrimpWorth")
.withIndex("by_url_user", (q) => q.eq("url", url).eq("userId", user._id))
.first();
});
const shrimpWorth = v.object({
url: v.string(),
count: v.number(),
userId: v.id("users"),
});

export const getShrimpCountForResource = queryWithUser(({ db, user }, { url }) => {
return db
.query("shrimpWorth")
.withIndex("by_url_user", (q) => q.eq("url", url).eq("userId", user._id))
.first();
});
No description
No description
5 Replies
ballingt
ballingt10mo ago
Yeah that's a lot! How big are these shrimpWorth documents? Looks like ~850kB per call, does the number of calls look right to you?
magicseth
magicsethOP10mo ago
Number of calls is probably right. Each record is a url a count and a userid
ballingt
ballingt10mo ago
Do the the other calls that take much less bandwidth also use queryWithUser?
magicseth
magicsethOP10mo ago
That's it! no index on clerkID Is there a way to see daily bandwidth consumption per function? The monthly stats make it hard to see how much improvement I've made by getting rid of filter (filter is still a footgun!)
jamwt
jamwt10mo ago
I’ll let the team answer about the dashboard, but for production projects, we’d really recommend hooking up a log stream to axiom or datadog. There’s a huge amount of visibility available there.

Did you find this page helpful?