It is due to a call to isAuthenticated, which calls getAuthenticatedUser. When running in a Daemon thread the user is not being cached in the UserContext rather queried from the DB by UUID every time any service method is called, which is slow. See https://github.com/openmrs/openmrs-core/blob/master/api/src/main/java/org/openmrs/api/context/Context.java#L610
isAuthenticated should simply return true, if isDaemonThread returns true.
Another way to fix it, would be storing the Deamon user in UserContext, but maybe there was some reasoning behind not doing so at the first place. Daniel Kayiwa, Wyclif Luyima, [~djazayeri], do you have any insights?