Avoid calling count unless it is required
See original GitHub issueIt is checking the count for every query, but isn’t using it for anything AFAICT except hasNextPage
DjangoObjectType
and DjangoConnectionField
[4.490] SELECT COUNT(*) AS "__count"
FROM "nsproperties_apt"
[0.159] SELECT "nsproperties_apt"."id", ...
This is a massive performance hit on postgresql. If I am selecting only 10 items and I don’t ask for the count then it should not call count. Even if the number of records is < 10 it still calls count.
For hasNextPage you can just iterate one past.
Related to #162 - it would be nice to get totalCount when we need it, but only pay the performance price then.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:15
Top Results From Across the Web
python - How to I add to this count without it resetting? Is there ...
Your issue is that the "age" variable will be resetted to 0 every single time the function will be called. The reason for...
Read more >CA1827: Do not use Count/LongCount when Any can be used
This rule flags the Count and LongCount LINQ method calls used to check if the collection has at least one element. These method...
Read more >Avoid Using COUNT() in SQL When You Could Use EXISTS()
It depends. If your database supports LIMIT without ORDER BY, then this might be as good as EXISTS. But if ORDER BY is...
Read more >Make every lead count: Avoiding missed calls, ghost form ...
This process requires at least 5 steps, and that's if everything goes as planned. Not to mention that by the time the employee...
Read more >Rules for Political Campaign Calls and Texts
In general, robocalls and robotexts to mobile phones require prior consent and ... If the calling party is a business or corporate entity, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@crucialfelix how do you go about using
SimplifiedDjangoConnectionField
? I tried using it instead ofDjangoFilterConnectionField
, so I usedDjangoFilterConnectionField
instead ofDjangoConnectionField
. That didn’t work, so I dug into the code a bit and found this bit of code that usesDjangoFilterConnectionField
.