- M:N
- outer join
- 스택
- 뷰
- Vue
- migrations
- 백트래킹
- distinct
- stack
- 그리디
- update
- 큐
- delete
- ORM
- SQL
- 통계학
- N:1
- regexp
- Queue
- Django
- 트리
- Article & User
- Tree
- 완전검색
- 이진트리
- count
- 쟝고
- DB
- drf
- create
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
목록select_related (2)
데이터 분석 기술 블로그

문제 상황prefetch_related 적용문제 해결 1단계입니다.게시글을 조회하면서 참조된 댓글까지 한 번에 조회합니다.# views.pydef index_4(request): # articles = Article.objects.order_by('-pk') articles = Article.objects.prefetch_related('comment_set').order_by('-pk') # articles = Article.objects.prefetch_related( # Prefetch('comment_set', queryset=Comment.objects.select_related('user')) # ).order_by('-pk') "111 queries includin..

select_relatedSQL의 INNER JOIN 쿼리를 활용합니다. 1:1 또는 N:1 참조 관계에서 사용합니다.문제 상황select_related 적용문제를 해결해 봅니다.게시글을 조회하면서 유저 정보까지 한 번에 조회해서 가져옵니다.# views.pydef index_2(request): # articles = Article.objects.order_by('-pk') articles = Article.objects.select_related('user').order_by('-pk') context = { 'articles': articles, } return render(request, 'articles/index_2.html', context)"11 qu..