F
Filamentβ€’5mo ago
Ahmad

Multi-tenancy tenantMenu performance (query count)

I've noticed that when the tenant menu is enabled to display all tenants a user belongs to, and the list of tenants is big, Filament performs a permission check (via a policy) for each resource across all tenants. This results in a significant number of unnecessary queries, as permissions should only be checked for the current tenant. Any reasons why this happens? and if there's a way to optimize or avoid this behavior?
3 Replies
neverything
neverythingβ€’5mo ago
Not sure if this is the same thing, but this helped me reduce the queries a lot: https://fxtwitter.com/neverything/status/1811662682745180510
πŸ” 4 ❀️ 10 πŸ‘οΈ 816
FxTwitter / FixupX
Silvan Hagen ⚑️ (@neverything)
Filament Tip: Save Some Queries πŸš€ The tenant switcher builds the entire navigation for each tenant just to get the first URL. This can lead to unnecessary queries, especially with complex menus and count badges. Here's a way to build the full menu only for the current tenant:
Ahmad
AhmadOPβ€’5mo ago
Will give it a try, thanks a lot! πŸ’š
neverything
neverythingβ€’5mo ago
Let me know how it goes, I'm using it in production now and it has reduced the queries a lot.
Want results from more Discord servers?
Add your server