Last active
June 7, 2019 22:52
-
-
Save goutomroy/26463f7367efd759a519367c52a5eae6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Don't | |
count = len(Entry.objects.all()) # Evaluates the entire queryset | |
# Do | |
count = Entry.objects.count() # Executes more efficient SQL to determine count | |
# Don't | |
qs = Entry.objects.all() | |
if qs: | |
pass | |
# Do | |
qs = Entry.objects.exists() | |
if qs: | |
pass | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment