I'm trying to decide if I want to use name__iexact=name
or name=name.lower()
in a filter quer开发者_如何学JAVAy. What gives better performance? If I'm storing name always as lowercase.
The strings are not bigger than 10 characters if that matters.
Doing name=name.lower() would perform better as you're only doing the lowercasing once (or it would not be needed since you mention you already stored it in lowercase) and then comparing with equality in the DB
Doing name__iexact=name will be a little slower as the ORM will perform a "LIKE" instead of "=", thus evaluating whether it matches for upper or lower case on each row.
精彩评论