From 729249f42bed83cba3fab56ab0f3e22f8da840d4 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 7 May 2015 16:59:13 -0400 Subject: [PATCH] Need to add the tables to the .select() to prevent N+1, not merely to the join --- data/model/legacy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/model/legacy.py b/data/model/legacy.py index 0d65796d5..a002cef41 100644 --- a/data/model/legacy.py +++ b/data/model/legacy.py @@ -2828,7 +2828,7 @@ def unstar_repository(user, repository): def get_user_starred_repositories(user, limit=None, page=None): """ Retrieves all of the repositories a user has starred. """ query = (Repository - .select() + .select(Repository, User, Visibility) .join(Star) .switch(Repository) .join(User)