From 91963c17a0f7cc611a6d0d2b038bc7ec8fc090fb Mon Sep 17 00:00:00 2001 From: Jake Moshenko Date: Fri, 9 Sep 2016 15:40:40 -0400 Subject: [PATCH] Remove a join to slightly optimize the gc query. --- data/model/repository.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/data/model/repository.py b/data/model/repository.py index a1b8196e1..24d82e697 100644 --- a/data/model/repository.py +++ b/data/model/repository.py @@ -163,11 +163,10 @@ def garbage_collect_repo(repo, extra_candidate_set=None): .where(RepositoryTag.repository == repo.id, Candidate.id << candidates_orphans)) - direct_referenced = (Candidate - .select(Candidate.id) - .join(RepositoryTag) + direct_referenced = (RepositoryTag + .select(RepositoryTag.image) .where(RepositoryTag.repository == repo.id, - Candidate.id << candidates_orphans)) + RepositoryTag.image << candidates_orphans)) referenced_candidates = (direct_referenced | ancestor_referenced)