Message ID | 20180810080106.10714-8-stewart@linux.ibm.com |
---|---|
State | Accepted |
Headers | show |
Series | Performance for ALL THE THINGS! | expand |
On Fri, 2018-08-10 at 18:01 +1000, Stewart Smith wrote: > 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> I wasn't able to see anything notable in this locally but it also didn't harm performance so Reviewed-by: Stephen Finucane <stephen@that.guru> Stephen > --- > patchwork/views/__init__.py | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/patchwork/views/__init__.py b/patchwork/views/__init__.py > index 96fd0798af5a..64d3d5f9f22d 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.compat import is_authenticated > from patchwork.filters import Filters > @@ -27,6 +28,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,8 @@ def generic_list(request, project, view, view_args=None, filter_settings=None, > patches = patches.only('state','submitter','delegate','project','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) >
diff --git a/patchwork/views/__init__.py b/patchwork/views/__init__.py index 96fd0798af5a..64d3d5f9f22d 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.compat import is_authenticated from patchwork.filters import Filters @@ -27,6 +28,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,8 @@ def generic_list(request, project, view, view_args=None, filter_settings=None, patches = patches.only('state','submitter','delegate','project','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)
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> --- patchwork/views/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)