Created
April 27, 2020 18:31
-
-
Save susmithagudapati/b71e64579da59beb56e26c1ac4ed5f11 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
# these 2 queries are faster because upc & id are unique and indexed. | |
product = Product.objects.get(upc='PXO01') | |
product = Product.objects.get(id=33) | |
# this is much slower than above queries because name isn't indexed. | |
product = Product.objects.get(name='Neon Shoes') | |
# this query can have multiple matches which hinders query performance. | |
product = Product.objects.get(name__startswith='Neon') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment