mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
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: moson-mo <mo-son@mailbox.org>
This commit is contained in:
parent
286834bab1
commit
5669821b29
1 changed files with 3 additions and 7 deletions
|
@ -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")
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue