강의

멘토링

로드맵

Inflearn Community Q&A

u6tory0892's profile image
u6tory0892

asked

Django with determination! Make Pinterest with Django: From the ground up to deployment

Like 갯수 구현 방법 차이에 대한 질문

Written on

·

193

0

article에서 like 갯수를 불러오는 방법에 강사님께서 사용하신 방법과 다르게

article에서 LikeRecord.objects.filter(article__pk=pk).count()하는 방법도 있을텐데요.

like 갯수를 따로 저장하려면 transaction이 필요하지만,

.count() 를 쓸 경우에는 transaction이 필요없고, like 갯수를 올리는 과정도 빠져서

서버에 대한 부하도 더 적을 것 같은데

article 모델에 like 갯수를 따로 필드로 만들어서 적용하신 이유가

transaction을 소개하기 위한 이유 외에 혹시 다른 장점이 있는 것인가요?

like가 많아지면 오히려 filter().count()로 인한 쿼리 부하가 더 비용으로 발생할 수 있는 것인지..

dockerdjangopython

Answer

This question is waiting for answers
Be the first to answer!
u6tory0892's profile image
u6tory0892

asked

Ask a question