Skip to content

Commit

Permalink
Optimize a query to improve export performance
Browse files Browse the repository at this point in the history
closes #3259
  • Loading branch information
dralley committed Sep 28, 2023
1 parent 6129f3d commit 0502669
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES/3259.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improved performance of exports significantly in some circumstances by optimizing a query.
6 changes: 3 additions & 3 deletions pulp_rpm/app/models/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,11 @@ def artifacts_for_version(version):
django.db.models.QuerySet: The artifacts that are contained within this version.
"""
qs = Artifact.objects.filter(content__pk__in=version.content)
artifacts_pk = set(Artifact.objects.filter(content__pk__in=version.content).values_list("pulp_id", flat=True))
for tree in DistributionTree.objects.filter(pk__in=version.content):
qs |= tree.artifacts()
artifacts_pk |= set(tree.artifacts().values_list("pulp_id", flat=True))

return qs
return Artifact.objects.filter(pk__in=artifacts_pk)

class Meta:
default_related_name = "%(app_label)s_%(model_name)s"
Expand Down

0 comments on commit 0502669

Please sign in to comment.