Repository navigation
[PULP-2474] Optimize Maven repository metrics counts - #541
Merged
Merged
Conversation
kdelee
force-pushed
the
pulp-2474-metrics-precompute
branch
2 times, most recently
from
October 14, 2026 18:07
e5062bb to
eaec692
Compare
Addresses PULP-2474.\nImplements the query consolidation suggested in pulp#539.
kdelee
force-pushed
the
pulp-2474-metrics-precompute
branch
from
October 14, 2026 18:07
eaec692 to
3ab63fa
Compare
Contributor
Author
|
GABI benchmark compared the existing three-query implementation with the new single-query Django aggregate. Existing SQL pattern: SELECT COUNT(*)
FROM (
SELECT DISTINCT group_id, artifact_id
FROM maven_mavenpackage
WHERE content_ptr_id IN (
SELECT unnest(content_ids)
FROM core_repositoryversion
WHERE pulp_id = '<version>'
)
) packages;
SELECT COUNT(*)
FROM (
SELECT DISTINCT
group_id,
artifact_id,
REGEXP_REPLACE(version, '-[^-]+$', '')
FROM maven_mavenpackage
WHERE content_ptr_id IN (
SELECT unnest(content_ids)
FROM core_repositoryversion
WHERE pulp_id = '<version>'
)
) versions;
SELECT COUNT(*)
FROM (
SELECT DISTINCT group_id, artifact_id, version
FROM maven_mavenpackage
WHERE content_ptr_id IN (
SELECT unnest(content_ids)
FROM core_repositoryversion
WHERE pulp_id = '<version>'
)
) builds;The API executed these as three separate database queries. New SQL shape: SELECT
COUNT(DISTINCT (group_id, artifact_id)),
COUNT(DISTINCT (
group_id,
artifact_id,
REGEXP_REPLACE(version, '-[^-]+$', '')
)),
COUNT(DISTINCT (group_id, artifact_id, version))
FROM maven_mavenpackage
WHERE content_ptr_id IN (
SELECT unnest(content_ids)
FROM core_repositoryversion
WHERE pulp_id = '<version>'
);Results matched exactly. Single-request results: Three concurrent requests: Summary: |
Backport to 0.34: 💚 backport PR created✅ Backport PR branch: Backported as #542 🤖 @patchback |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The repository metrics endpoint runs three separate COUNT(DISTINCT) queries over MavenPackage content. Combine them into one Django aggregate query using PostgreSQL row-valued DISTINCT expressions.
This preserves the API and exact results while reducing production-scale GABI latency from about 9.4–9.8s to 3.6–3.8s under three concurrent requests.
Tests: