On Bahmni, we limit the number of locations that a user can login by using a Location Tag called "Login Location". We use Locationservice.getLocationsHavingAllTags to retrieve this. It takes quite a long time even when the result size is small.
The reason for this is that the service retrieves all Locations to memory and checks whether the location tags are correct. If we move this to the DAO layer and do the location filtering by tags in hql, performance will improve drastically.