I want to know if the following query is being optimized by django. I have an address model that is indexed on the field User but not on the field zip_code.
When I do:
Address.objects.get(user=user, zip_code=zip_code)
What I hope happens is that the query first takes advantage of the index to return addresses associated with the user, and then it iterates through the list of addresses for that user and matches the one that has the given zip_code.
However, I'm afraid that this query will not take advantage of the fact that I have the user model indexed on users and will instead iterate through all addresses trying to make sure both the user and zip_code match.