diff mbox series

[06/11] check distinct(user) based on just user_id

Message ID 20180810080106.10714-7-stewart@linux.ibm.com
State Accepted
Headers show
Series Performance for ALL THE THINGS! | expand

Commit Message

Stewart Smith Aug. 10, 2018, 8:01 a.m. UTC
The logic to display the Check(s) on the patch list wants to really do a
DISTINCT(user_id,context) ORDER BY DATE query, but with Django that is
currently a bit Too Hard (at least for me).

But what we can do is from python just use the user_id rather than the
user object itself. Same functionality, no join or prefetching users.

This saves a couple of hundred queries on the linuxppc/list/ view and
makes loading it about 4x faster in terms of time spent in the db.

Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
---
 patchwork/models.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stephen Finucane Aug. 31, 2018, 2:11 p.m. UTC | #1
On Fri, 2018-08-10 at 18:01 +1000, Stewart Smith wrote:
> The logic to display the Check(s) on the patch list wants to really do a
> DISTINCT(user_id,context) ORDER BY DATE query, but with Django that is
> currently a bit Too Hard (at least for me).
> 
> But what we can do is from python just use the user_id rather than the
> user object itself. Same functionality, no join or prefetching users.
> 
> This saves a couple of hundred queries on the linuxppc/list/ view and
> makes loading it about 4x faster in terms of time spent in the db.
> 
> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>

Easy win.

Reviewed-by: Stephen Finucane <stephen@that.guru>

Stephen

> ---
>  patchwork/models.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/patchwork/models.py b/patchwork/models.py
> index 15224ad69cfa..d356a6379ac3 100644
> --- a/patchwork/models.py
> +++ b/patchwork/models.py
> @@ -539,7 +539,7 @@ class Patch(SeriesMixin, Submission):
>  
>          for check in self.check_set.all():
>              ctx = check.context
> -            user = check.user
> +            user = check.user_id
>  
>              if user in unique and ctx in unique[user]:
>                  # recheck condition - ignore the older result
diff mbox series

Patch

diff --git a/patchwork/models.py b/patchwork/models.py
index 15224ad69cfa..d356a6379ac3 100644
--- a/patchwork/models.py
+++ b/patchwork/models.py
@@ -539,7 +539,7 @@  class Patch(SeriesMixin, Submission):
 
         for check in self.check_set.all():
             ctx = check.context
-            user = check.user
+            user = check.user_id
 
             if user in unique and ctx in unique[user]:
                 # recheck condition - ignore the older result