STARIONGROUP / COMET-WebServices-Community-Edition

The Concurrent Design Platform Web Services that are compliant with ECSS-E-TM-10-25 Annex A and Annex C
https://www.stariongroup.eu
Other
11 stars 5 forks source link

When a Person has as a PersonRole in which the PersonPermission for the Person ClassKind is set to READ doing a GET on SiteDirectory has poor performance #339

Closed samatstariongroup closed 8 months ago

samatstariongroup commented 8 months ago

Prerequisites

Description

In the case when there are many EngineeringModels available in a server and when each model has multiple Particpants, a READ on SiteDirectory has poor performance in the following case:

Steps to Reproduce

System Configuration

COMET Web Services version: 7.1.1

antoineatstariongroup commented 8 months ago

First investigation with the 2 defined configurations :

Associated dumps are contained in the following archive: (each db have setup explained in the issue but instead of having 20 models, there are 30 models)

cdp4db_dumps.zip

Here are results :

new_test_result.txt old_test_result.txt

It seams the we do have a less performant login with the role MODIFY_OWN_PERSON but performance are way better with version 8.0.0-rc25

antoineatstariongroup commented 8 months ago

Investigation: new information;

The PermissionService for READ action, at SiteDirectory level can hit the database on multiple cases: if the PersonAccessRightKind is READ_IF_PARTICIPANT (not on the current scope) or MODIFY_OWN_PERSON.

On that last case, for each Person that is retrieved on the database, a new check is done against the database to check whether the person is a participant within a model that the logged person is also a participant.

samatstariongroup commented 8 months ago

Investigation: new information;

The PermissionService, at SiteDirectory level can hit the database on multiple cases: if the PersonAccessRightKind is READ_IF_PARTICIPANT (not on the current scope) or MODIFY_OWN_PERSON.

On that last case, for each Person that is retrieved on the database, a new check is done against the database to check whether the person is a participant within a model that the logged person is also a participant.

@antoineatrhea that was my suspicion, i think the service is already registered as a per-request, so we can apply some kind of caching routinel Or we can do a more complex, less naive SQL statement in a DAO class to suit the needs and make it more performant.

antoineatstariongroup commented 8 months ago

@samatrhea making BULK check would be more efficient : instead of checking one instance of each type, why not checking all instances of each type directly ? only one SQL statement would then be made (without any changes on current statement), just need to re-think the way that permission and filtering are done.