Joins and Lazy vs Eager Loading
Avoid N+1 queries when traversing relations.
Querying Across Tables
Sometimes you filter parents by their children's data. A join lets one query span two related tables at once. 🔀
Write a join
Call join() on a query to pull a related model in, then filter on either side as one combined query.
q = User.query.join(Post).filter(Post.title == "Hi")All lessons in this course
- Fetch Rows with query and get
- Filter, Order, and Limit Results
- Define Relationships and Foreign Keys
- Joins and Lazy vs Eager Loading