Reputation: 3716
I'm currently in the process of optimizing my Django app, which is acting as an API for my front-end with the Django Rest Framework. While running my server in debug mode, I've noticed that every time a queryset gets executed, there's a query run right before it that always looks like this:
SELECT COUNT('*') AS "__count" FROM "table_name WHERE ..."
The ... part always mirrors the query that returns the objects that I want. I'm unsure if this is only run in debug, something that the QuerySet
object does innately, or an error with my code. Would appreciate some insight as to why this is happening and if it's something I need to worry about
Upvotes: 4
Views: 898
Reputation: 9492
This occurs in Django Rest Framework when you are using paging on a list view:
Upvotes: 4