What is the purpose of Django's select_related method?
Correct answer
A. To optimize database queries by reducing the number of queries
16 views
A. To optimize database queries by reducing the number of queries
16 views
select_related() optimises queries by reducing their number. It follows ForeignKey and OneToOne relationships with an SQL JOIN, fetching the related objects in the same query.
It is the standard cure for the "N+1 queries" problem on single-valued relationships.
Keep preparing with more Computer Science MCQs on MCQsExam.com.
Not sure why the answer is A? Ask here and get an explanation.