/tools/metrics-prometheus blocks other http requests

Using mysql plugin for index and S3 for storage.
6M entries in Resources table.

GET /tools/metrics-prometheus does some heavy sql requests such as:
SELECT CAST(COALESCE(SUM(uncompressedSize), 0) AS UNSIGNED INTEGER) FROM AttachedFiles

All other Orthanc rest api requests freeze until metrics collection finishes.

Hello,

This is known limitation, as the MySQL plugin is not designed for speed right now. There are other pending changes related to performance in the mainline:
https://bitbucket.org/sjodogne/orthanc-databases/src/default/MySQL/NEWS

If your focus is on performance, please switch to PostgreSQL, as explained in the Orthanc Book:
https://book.orthanc-server.com/faq/scalability.html

Sébastien-