KEYCLOAK-4858: Slow query performance for client with large data volume
- Changing RESOURCE_SERVER PK to the client ID. - Changing FK on children of RESOURCE_SERVER. - Use direct fetch of ResourceServer through ID/PK to avoid a lot of implicit Hibernate flush.
This commit is contained in:
1 parent
1fb8846a7a
commit
c1664478d9
44 files changed
+154
-195
No files matched your search
+1
-1
@@ -108,7 +108,7 @@ public class ClientPolicyProviderFactory implements PolicyProviderFactory<Client
|
||||
PolicyStore policyStore = storeFactory.getPolicyStore();
|
||||
ClientModel removedClient = ((ClientRemovedEvent) event).getClient();
|
||||
ResourceServerStore resourceServerStore = storeFactory.getResourceServerStore();
|
||||
ResourceServer resourceServer = resourceServerStore.findByClient(removedClient.getId());
|
||||
ResourceServer resourceServer = resourceServerStore.findById(removedClient.getId());
|
||||
|
||||
if (resourceServer != null) {
|
||||
policyStore.findByType(getId(), resourceServer.getId()).forEach(policy -> {
|
||||
|
||||
+1
-1
@@ -222,7 +222,7 @@ public class RolePolicyProviderFactory implements PolicyProviderFactory<RolePoli
|
||||
}
|
||||
|
||||
private void updateResourceServer(ClientModel clientModel, RoleModel removedRole, ResourceServerStore resourceServerStore, PolicyStore policyStore) {
|
||||
ResourceServer resourceServer = resourceServerStore.findByClient(clientModel.getId());
|
||||
ResourceServer resourceServer = resourceServerStore.findById(clientModel.getId());
|
||||
|
||||
if (resourceServer != null) {
|
||||
policyStore.findByType(getId(), resourceServer.getId()).forEach(policy -> {
|
||||
|
||||
+1
-1
@@ -181,7 +181,7 @@ public class UserPolicyProviderFactory implements PolicyProviderFactory<UserPoli
|
||||
RealmModel realm = ((UserRemovedEvent) event).getRealm();
|
||||
ResourceServerStore resourceServerStore = storeFactory.getResourceServerStore();
|
||||
realm.getClients().forEach(clientModel -> {
|
||||
ResourceServer resourceServer = resourceServerStore.findByClient(clientModel.getId());
|
||||
ResourceServer resourceServer = resourceServerStore.findById(clientModel.getId());
|
||||
|
||||
if (resourceServer != null) {
|
||||
policyStore.findByType(getId(), resourceServer.getId()).forEach(policy -> {
|
||||
|
||||
Reference in new issue
Block a user