Closed myungseokang closed 7 years ago
I think doesn't need to optimize. Cause there is no bottleneck. If each data have different author, then there are no duplicated queries. It depends on the data. All duplicated queries on the index are selected by primary key. It is fast enough. There is way to optimize, but it would be have problem with readability. It is enough to optimize when we have a problem with slow queries. We have to focus on to implement a feature.
Any improvements made anywhere besides the bottleneck are an illusion. — Gene Kim
We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%. — Donald Ervin Knuth
But just adding 2 lines to PresentationList class, query's count decrease 11 to 2. I do not think I need to leave a visible inefficient part.
class PresentationList(PaginationMixin, ListView):
model = Presentation
paginate_by = 9
context_object_name = 'presentations'
ordering = ['-pk']
# here
def get_queryset(self):
return Presentation.objects.all().select_related('author')
@Leop0ld Do it!
@qkraudghgh I need to review other views. I create PR if I finish task.
:+1:
I saw index page's SQL query count maybe 11. many duplicated query exists. So need to optimizing query.