Hi! Just getting started with Convex for a small side project and I'm a bit surprised with the query bandwidth being used for such few operations.
-
When I try and check bandwidth usage per function the table is blank (screenshot attached) I assume this is a bug.
-
Is there a way to optimise bandwidth besides indexes? we have a lot of permission checks so queries calling queries and I suspect that's racking up the bandwidth, would be good to understand how caching comes into play here.
For example, this gets called on almost every query:
export const checkWorkspaceAccess = query({
args: {
workspaceId: v.id('workspaces')
},
handler: async (ctx, args) => {
const userId = await getAuthUserId(ctx)
if (!userId) throw new Error('Not authenticated')
const userWorkspace = await ctx.db
.query('userWorkspaces')
.withIndex('by_workspace', q => q.eq('workspaceId', args.workspaceId))
.filter(q => q.eq(q.field('userId'), userId))
.first()
if (!userWorkspace) throw new Error('Not authorized')
return { hasAccess: true, userId }
}
})
Is this recommended and is there a better practice?