[Answered ]-Django fastest request between query and sub query

2πŸ‘

βœ…

In both situations, you are not triggering the queryset to be evaluated. filter does nothing but composing sql statement in the underline implementation, so you never hit the database in either of the cases, you were just composing several sql statement that sits in your program. Only when you start using the variables then django starts to do the queryset evaluation.

Django doc about querysets are lazy. If every orm statement is hitting the databsase it’s not going to be optimal.

πŸ‘€Shang Wang

Leave a comment