Skip to content

Instantly share code, notes, and snippets.

@susmithagudapati
Created April 28, 2020 17:56
Show Gist options
  • Save susmithagudapati/36749ceeeb9724ec9a2c81f9d026c663 to your computer and use it in GitHub Desktop.
Save susmithagudapati/36749ceeeb9724ec9a2c81f9d026c663 to your computer and use it in GitHub Desktop.
# executed by Python
%timeit if Product.objects.all(): print("valid")
4.19 ms ± 118 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
# executed in the database
%timeit Product.objects.exists()
226 µs ± 4.73 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment