Thursday, September 24, 2020

Double query to retrieve a Paginator's page


Paginator.page() when called for the first time will trigger the evaluation of the cached property "count", which performs a COUNT query on the database. It will generally happen every time, since a new Paginator object is made for each new request.
The problem here is that the COUNT query costs almost the same as the main query which retrieves the page's items, so in effect it's doubling the needed query.
How can I avoid that duplication?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1debc300-2413-4a7c-96e6-c56496ed7a3an%40googlegroups.com.

No comments:

Post a Comment