helpful-traffic-4919
06/03/2024, 8:55 AMclass User implements Namespace {}
class Team implements Namespace {
related: {
members: User[];
};
permits = {
containsUser: (ctx: Context): boolean => this.related.members.includes(ctx.subject),
};
}
class Project implements Namespace {
related: {
teams: Team[];
};
permits = {
edit: (ctx: Context): boolean =>
this.related.teams.traverse((team) => team.permits.containsUser(ctx)),
};
}
I.e. Project
has (one as it happens) associated Team
, with a Team
having many members. And `Team`s can have a lot of members - thousands to tens of thousands.
From looking at the queries this leads to Keto running for a check operation for the edit
permission for a User
on a Project
, we found that it runs a SQL query per User
associated with the team, as part of its expand subject set flow (refs: traverser.go / engine.go)
This doesn’t have great scaling characteristics, so I was wondering:
• If we’re modelling this correctly - is there a way to model this that would not lead to linear query scaling against team user membership?
• Or if not, are there any plans to tune the optimise the performance for cases such as this?steep-lamp-91158
helpful-traffic-4919
06/03/2024, 11:39 AM