SmileyChris / easy-thumbnails

Easy thumbnails for Django
http://easy-thumbnails.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
1.39k stars 319 forks source link

Remove additional queries looking for cached dimensions #501

Open volksman opened 6 years ago

volksman commented 6 years ago

It seems this has been in the package since 2014 but I just noticed it today while trying to optimize server response times. I noticed that when I asked for with width and height of an image I was generating at least 1 extra query per image.

After reviewing the code it looks like a pretty easy win to disable the query to check if there is a dimension cached for a particular image which is being called regardless of the THUMBNAIL_CACHE_DIMENSIONS setting. This seems counter intuitive to me so I've added an if statement to check for the setting before running extra queries to find dimensions.