I have a simple query in my django.
values = ['profile_url', 'name','profit']
home = Home.objects.get(homename='Valley Homes')
user_filters = {"name":"san agustin", "age":21}
user_excludes = {}
users = (User.objects.annotate(distinct_user=ArrayAgg(*values, distinct=True)).filter(home=home, **user_filters).select_related(*user_filters.keys()).exclude(**user_excludes).values(*values))
On local ec2 instance it takes up to 4 seconds to query
On docker it takes up to 84 seconds which is horrible.
I thought using select_related would shorten time but still it doesnt.
Really need help in improving performance on docker. How can i make it faster like in local?
I checked memory and CPU it doesnt seem to be the problem, it spikes up to 13% during the query but quickly goes back to 1% after that.