python - Django Rest framework pagination performance issue -
i have view inherits listapiview , displays list of objects. performance reasons, trying implement pagination. :
from rest_framework.pagination import pagenumberpagination class largeresultssetpagination(pagenumberpagination): page_size = 2 page_size_query_param = 'page_size' max_page_size = 2 class raceeventlistview(callserializereagerloadingmixin, listapiview): serializer_class = raceeventlistserializer queryset = raceevent.objects.all() pagination_class = largeresultssetpagination
following documentation http://www.django-rest-framework.org/api-guide/pagination/
without pagination 1 query made. select * raceevent
with pagination 2 queries made. select * raceevent
, select * raceevent limit 2
.
as result, not achieve better performance. should do, in order limit 1 queries when using pagination
the second query calculating total amount of objects. json object of response has attribute count...in order calculate value query made.
Comments
Post a Comment