Note that this issue has been resolved in the upcoming releases of 2.37, 2.39, and 2.40. It was also fixed in 2.38.3 which was released yesterday.
In affected versions of DHIS2, as Enrico mentioned, you can avoid this issue by setting system.program_rule.server_execution = off
in dhis.conf.
Please let us know if you continue to see any performance issues after upgrading to a version in which this issue has been fixed (2.37.10, 2.38.3, 2.39.2, 2.40.0)