data-hub
data-hub copied to clipboard
[Improvement][Perf]: WorkspaceHelper::isAllowed creating hundreds of database queries for listings
Improvement description
WorkspaceHelper::isAllowed will run a DB query for each item in the listing, including relations: https://github.com/pimcore/data-hub/blob/f78112706afa25a590f3519d9ee9364df742ea2f/src/WorkspaceHelper.php#L280-L282
In my test, fetching 50 products and related images will run the query 426 times, accounting for about 30% of the total runtime.
Looking at the code, it seems it should be possible to avoid these queries completely by creating a special in-memory (in cache) data structure optimized for this check and running the check as fast as possible on that specific structure.
Edit: when the listing is fully cached (all elements fully resolved from cache), the listing will still run 546 queries, but 426 of them are still this permission check, that's 80% of all the work done, accounting for 40% of total runtime.