Closed thoraj closed 3 months ago
@sagilio @sociometry @AsakusaRinne
@AsakusaRinne
/cc @sagilio
We plan to add the new option AutoLoadPolicy
(#295) to control this behavior, the changes will also try implemented in the v1 version.
Closed as resolved
We are using Casbin extensively in our system.
We're using Casbin.Net 1.12.2 and Casbin.NET.Adapter.EFCore 1.80
As the number of policies grows we are experiencing performance issues.
A while back we started filterering policies per tenant. So now we:
So the adapter has already loaded all policies when handed to the Enforcer constructor
However it seems all policies are still loaded when creating the enforcer. We have instrumented our code and it shows that:
The adapter (correctly) issues a query which filters the policies
SELECT c.id, c.ptype, c.v0, c.v1, c.v2, c.v3, c.v4, c.v5 FROM casbin_rule AS c WHERE ((c.ptype = @__policyType_0) AND (c.v0 = @__field_1)) AND (c.v1 = @__field_2)
The enforcer issues another query which is NOT filtered.
SELECT c.id, c.ptype, c.v0, c.v1, c.v2, c.v3, c.v4, c.v5 FROM casbin_rule AS c
The second non-filtered query is issued while the Enforcer is being constructed.
Is there some way we can prevent this from happening such that only policies for the tenant are loaded?
-- Thor A. Johansen