Verified Commit 5669821b authored by Mario Oenning's avatar Mario Oenning
Browse files

perf: tweak some queries in mkpkglists



We can omit the "distinct" from some queries
because constraints in the DB ensure uniqueness:

* Groups sub-query
PackageGroup: Primary key makes "PackageID" + "GroupID" unique
Groups: Unique index on "Name" column
-> Technically we can't have a package with the same group-name twice

* Licenses sub-query:
PackageLicense -> Primary key makes "PackageID" + "LicenseID" unique
Licenses -> Unique index on "Name" column
-> Technically we can't have a package with the same license-name twice

* Keywords sub-query:
PackageKeywords -> Primary key makes "PackageBaseID" + "KeywordID" unique
(And a Package can only have one PackageBase)
Keywords -> Unique index on "Name" column
-> Technically we can't have a package with the same Keyword twice

* Packages main-query:
We join PackageBases and Users on their primary key columns
(which are guaranteed to be unique)
-> There is no way we could end up with more than one record for a Package

Signed-off-by: Mario Oenning's avatarmoson-mo <mo-son@mailbox.org>
parent 286834ba
Pipeline #36534 passed with stages
in 2 minutes and 27 seconds
......@@ -94,7 +94,7 @@ def get_extended_fields():
models.PackageDependency.DepName.label("Name"),
models.PackageDependency.DepCondition.label("Cond"),
)
.distinct()
.distinct() # A package could have the same dependency multiple times
.order_by("Name"),
# PackageRelation
db.query(models.PackageRelation)
......@@ -105,7 +105,7 @@ def get_extended_fields():
models.PackageRelation.RelName.label("Name"),
models.PackageRelation.RelCondition.label("Cond"),
)
.distinct()
.distinct() # A package could have the same relation multiple times
.order_by("Name"),
# Groups
db.query(models.PackageGroup)
......@@ -116,7 +116,6 @@ def get_extended_fields():
models.Group.Name.label("Name"),
literal(str()).label("Cond"),
)
.distinct()
.order_by("Name"),
# Licenses
db.query(models.PackageLicense)
......@@ -127,7 +126,6 @@ def get_extended_fields():
models.License.Name.label("Name"),
literal(str()).label("Cond"),
)
.distinct()
.order_by("Name"),
# Keywords
db.query(models.PackageKeyword)
......@@ -140,7 +138,6 @@ def get_extended_fields():
models.PackageKeyword.Keyword.label("Name"),
literal(str()).label("Cond"),
)
.distinct()
.order_by("Name"),
# Co-Maintainer
db.query(models.PackageComaintainer)
......@@ -155,7 +152,7 @@ def get_extended_fields():
models.User.Username.label("Name"),
literal(str()).label("Cond"),
)
.distinct()
.distinct() # A package could have the same co-maintainer multiple times
.order_by("Name"),
]
query = subqueries[0].union_all(*subqueries[1:])
......@@ -230,7 +227,6 @@ def _main():
PackageBase.SubmittedTS.label("FirstSubmitted"),
PackageBase.ModifiedTS.label("LastModified"),
)
.distinct()
.order_by("Name")
)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment