You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
what would be the benefit? without pagination, the whole queryset will be listed anyway, right? so the current code version is already optimized and saves the count() call.
Hi,
the
__len__
implementation ofTableQuerysetData
class only checks for the presence of thepaginator
to determine to use.count()
overlen()
: https://github.com/jieter/django-tables2/blob/master/django_tables2/data.py#L150Unfortunately,
__len__
of a QuerySet is implemented to fetch all records and usinglen()
on the result list: https://github.com/django/django/blob/main/django/db/models/query.py#L302This can be a really expensive operation. I suggest to change the condition to
to utilize the much faster
.count()
query in case of a QuerySet.The text was updated successfully, but these errors were encountered: