Anything beyond 10 minutes is not recommended. I would sink this immediately back to 10 minutes.
This can be a laborious problem to diagnose, but the best way to get started it to look at what Glowroot can reveal. Here is an example
Wow, this looks brutal. 10 queries, each of them taking more than 200 seconds to complete.
/app/api/40/analytics
ERROR
Transaction type: Web
Transaction name: /app/api/40/analytics
Error: java.io.IOException: Broken pipe
exception
Start: 2026-07-09 7:22:11.020 am (+02:00)
Duration: 1,383,045.9 milliseconds
Overall, the process took 23 minutes, but note the “Broken pipe”. That means the web proxy killed the connection already.
I don’t know exactly what the problem is in this example, but it looks like the user is asking for some program indicators which are very complex. Each one of them takes a very significant amount of time to calculate. It can be also worthwhile to have a look at this document (which is a bit dated at this point, but does contain some possible levers you can use) Tracker performance at scale - DHIS2 Documentation Depending on your Postgres version, you should be sure that JIT is turned off. It causes unexpected performace degradation.
Custom indexes can be an option you can also explore. Indexes can dramatically speed up certain queries, but are of course not free. They come with a cost of storage and write performance. Careful testing may be required.
Lastly, you may find that the query plan (as revealed by Postgres) is simply not good. You may just have to request less data or use other strategies like SQL views to support retrieval of data which is specific to your workflow. If your analysis reveals particularly bad query plans, you can share them with us here, and we can advise more. Sometimes, we can optimize the way the SQL is generated or the syntax of the program indicator.
There is often not an easy answer, and it can depend a lot on configuration of your system, shape of your database, and the exact query which you are asking for. However, Glowroot can reveal very quickly where the bottleneck is. Whether it can be fixed easily is another problem.
Best regards,
Jason