[Django]-Django Query Performance Filtering Vs Foreign Key Set Lookup

5👍

Query 2 is exactly equivalent to the second line of Query 1. But since Query 1 also includes the first line, which does a separate Location lookup, it is necessarily slower.

If you don’t need the actual location object, then 2 is definitely the way to go.

Leave a comment