- Django
- Article & User
- 그리디
- outer join
- 쟝고
- N:1
- ORM
- 완전검색
- migrations
- DB
- Queue
- 백트래킹
- SQL
- count
- 이진트리
- 뷰
- 통계학
- 스택
- regexp
- 큐
- Vue
- update
- distinct
- Tree
- create
- 트리
- stack
- drf
- delete
- M:N
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
목록2024/05 (31)
데이터 분석 기술 블로그

HTTP Request Methods리소스에 대한 행위(수행하고자 하는 동작)를 정의합니다. HTTP verbs라고도 합니다.response status codesHTTP 요청이 성공적으로 완료되었는지 여부를 나타냅니다.

URL (Uniform Resource Identifier - 통합 자원 식별자)인터넷에서 리소스(자원)를 식별하는 문자열로 가장 일반적인 URI는 웹 주소로 알려진 URI입니다.웹에서 주어진 리소스의 주소로 워크 상에 리소스가 어디 있는지를 알려주기 위한 약속입니다.

API (Apllication Programming Interface)애플리케이션과 프로그래밍으로 소통하는 방법을 말합니다.클라이언트 - 서버처럼 서로 다른 프로그램에서 요청과 응답을 받을 수 있도록 만든 체계입니다.REST (Representaional State Transfer)API Server를 개발하기 위한 일종의 소프트웨어 설계 방법론으로 약속이지 규칙은 아닙니다.REST APIREST라는 설계 디자인 약속을 지켜 구현한 API입니다.REST에서 자원을 정의하고 주소를 지정하는 방법자원의 식별URI자원의 행위HTTP Methods자원의 표현JSON 데이터궁극적으로 표현되는 데이터 결과물

문제 상황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..

prefetch_relatedM:N 또는 N:1 역참조 관계에서 사용합니다. SQL이 아닌 Python을 사용한 JOIN을 진행합니다.문제 상황prefetch_related 적용문제를 해결해 봅니다.게시글을 조회하면서 참조된 댓글까지 한 번에 조회해서 가져옵니다.# views.pydef index_3(request): # articles = Article.objects.order_by('-pk') articles = Article.objects.prefetch_related('comment_set').order_by('-pk') context = { 'articles': articles, } return render(request, 'articles/index_3...

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..

annotateSQL의 GROUP BY 쿼리를 사용합니다.문제 상황annotate 적용문제를 해결해 봅시다.게시글을 조회하면서 댓글 개수까지 한 번에 조회해서 가져옵니다.# views.pydef index_1(request): # articles = Article.objects.order_by('-pk') articles = Article.objects.annotate(Count('comment')).order_by('-pk') context = { 'articles': articles, } return render(request, 'articles/index_1.html', context)댓글 개수 : {{ article.comment__count }}"11 qu..

Improve query같은 결과를 얻기 위해 DB 측에 보내는 쿼리 개수를 점차 줄여 조회합니다.1. 사전 준비데이터게시글 10개 / 댓글 100개 / 유저 5개모델 관계N:1 - Article:User / Comment:Article / Comment:ArticleN:M - Article:Userpython manage.py migratepython manage.py laoddata users.json articles.json comments.jsonInstalled 115 object(s) from 3 fixture(s)2. 종류annotateselect_relatedprefetch_relatedselect_related & prefetch_related