easy-thumbnails icon indicating copy to clipboard operation
easy-thumbnails copied to clipboard

Lots of duplicated queries

Open bixbyr opened this issue 2 years ago • 1 comments

I am generating a crazy huge number of queries on pages where I have a lot of thumbnails. The django-debug-toolbar is showing me this comes from some places where I am iterating through a query set and getting a thumbnail for each item. Is there a way to select_related or otherwise solve the N+1 problem here? I don't see anything in the documentation which seems like it would answer this.

bixbyr avatar May 30 '23 04:05 bixbyr

It will probably be hard with a select related, just because it's a template tag. I noticed the same as you, when rendering many thumbnails. It gets slow. I wonder if adding another cache layer could help - redis/memcached and the like would sure be much faster, than the Django ORM.

Adds more complexity, though. You could cache your template fragement, but that depends on your use case: https://docs.djangoproject.com/en/4.2/topics/cache/#template-fragment-caching

benzkji avatar Nov 04 '23 11:11 benzkji