filmov
tv
Django prefetch_related Examples|Django select_related and prefetch_related|Django n+1 Query Problem

Показать описание
In this video, I'm gonna be showing you what exactly is prefetch_related in Django. We will demonstrate Django prefetch_related by making use of an example project which has two models and these models are related to each other using a ManytoMany relationship. We will show you what exactly is the use case of Django prefetch_related by querying the Django models and showing the corresponding SQL queries being executed in the background by making use of django debug toolbar. We will then explain the problems with the default accessing method and specifically about the n+1 query problem in Django ORM. Then, we will fix the n+1 problem using Django prefetch_related. We will also talk about the underlying SQL queries being executed if we use prefetch_related. At the end, we will also talk about the difference between prefetch_related and select_related, when to use Django select_related and when to use Django prefetch_related and so on. This video is a part of Django Relationships series.
Subscribe | Code Band
Other videos in Code Band:
:) You Can Find Me On:
Subscribe | Code Band
Other videos in Code Band:
:) You Can Find Me On:
Комментарии