id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 28284 Paginator._check_object_list_is_ordered should not evaluate the entire queryset Tom Forbes Tom Forbes "The `_check_object_list_is_ordered` function in Paginator currently throws a warning if the queryset is unordered. As part of this warning the queryset is formatted using `{!r}`, which ends up calling the `__repr__` or `__str__` of each of the items in the QuerySet. This causes the entire queryset to be evaluated and all rows fetched, and if `__repr__` uses any foreign keys these are also fetched, resulting in a lot of queries. Warnings are also silent by default, and the string is *always* evaluated regardless of if the warning is displayed or not. Also, the warning is conditional: Pagination *may* yield inconsistent results. Some databases may vary, so to people who use these backends this change just introduced something that evaluates the entire queryset every time the Paginator is used for no particular reason. I propose that the warning is either replaced by a hard error, or the warning is changed to perhaps display the model name of the queryset, or some other information that doesn't require iterating the queryset." Cleanup/optimization closed Core (Other) 1.11 Normal fixed Accepted 1 0 0 0 0 0