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
COUNT(*) statements are expensive in postgres, so we should consider refactoring QuerySet count() calls (which do COUNT under the hood). Esp. in these cases, we basically double the execution time by first calling count() and then the query itself:
query_forecasts_for_project()
query_scores_for_project()
query_truth_for_project()
A better approach is to replace calling count() with simply iterating over the results, counting along the way, and terminating if the max is reached, making sure to call iterator() so that the server-side cursor (2000-rows chunks by default) is active - see [Change QuerySet calls to use iterator() #282].
The text was updated successfully, but these errors were encountered:
COUNT(*)
statements are expensive in postgres, so we should consider refactoring QuerySetcount()
calls (which do COUNT under the hood). Esp. in these cases, we basically double the execution time by first callingcount()
and then the query itself:query_forecasts_for_project()
query_scores_for_project()
query_truth_for_project()
A better approach is to replace calling
count()
with simply iterating over the results, counting along the way, and terminating if the max is reached, making sure to calliterator()
so that the server-side cursor (2000-rows chunks by default) is active - see [Change QuerySet calls to use iterator() #282].The text was updated successfully, but these errors were encountered: