diff options
author | Stewart Smith <stewart@linux.ibm.com> | 2018-08-10 18:01:02 +1000 |
---|---|---|
committer | Stephen Finucane <stephen@that.guru> | 2018-09-10 14:24:24 -0600 |
commit | 5b8b6fb5261dc2cb1c95bc82ab7a5466e6699d03 (patch) | |
tree | 8933f5ab3d979e6c32c6b99857a0c3cbe84cd055 | |
parent | 03981421196413e8f130a9aeff607fcca47952ca (diff) | |
download | patchwork-5b8b6fb5261dc2cb1c95bc82ab7a5466e6699d03.tar patchwork-5b8b6fb5261dc2cb1c95bc82ab7a5466e6699d03.tar.gz |
Be particular over check_set and series prefetch for /list/
At this point it shaves at most 1-2ms off the query time for
/linuxppc-dev/list/
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
-rw-r--r-- | patchwork/views/__init__.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/patchwork/views/__init__.py b/patchwork/views/__init__.py index f66963f..5942ded 100644 --- a/patchwork/views/__init__.py +++ b/patchwork/views/__init__.py @@ -19,6 +19,7 @@ from django.contrib import messages from django.shortcuts import get_object_or_404 +from django.db.models import Prefetch from patchwork.filters import Filters from patchwork.forms import MultiplePatchForm @@ -26,6 +27,8 @@ from patchwork.models import Bundle from patchwork.models import BundlePatch from patchwork.models import Patch from patchwork.models import Project +from patchwork.models import Check +from patchwork.models import Series from patchwork.paginator import Paginator @@ -290,7 +293,11 @@ def generic_list(request, project, view, view_args=None, filter_settings=None, 'name', 'date') # we also need checks and series - patches = patches.prefetch_related('check_set', 'series') + patches = patches.prefetch_related( + Prefetch('check_set', queryset=Check.objects.only( + 'context', 'user_id', 'patch_id', 'state', 'date'))) + patches = patches.prefetch_related( + Prefetch('series', queryset=Series.objects.only('name'))) paginator = Paginator(request, patches) |