Answer the question
In order to leave comments, you need to log in
Is aggregation more efficient?
Hello. There is code that calculates the rating of an entity in a very primitive way: the sum of all rating changes (-1 for "dislike", +1 for "like"). sum([vote.change for vote in self.votes.all()])
Would it be better (if so, how much?) to use aggregation instead?
self.votes.aggregate(Sum('change'))['change__sum'] or 0
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question