| |
@@ -84,6 +84,16 @@
|
| |
if packagename:
|
| |
query = BuildsLogic.filter_by_package_name(query, packagename)
|
| |
|
| |
+ from sqlalchemy.orm import joinedload
|
| |
+ # Loading relationships straight away makes running `to_dict` somewhat
|
| |
+ # faster, which adds up over time, and brings a significant speedup for
|
| |
+ # large projects
|
| |
+ query = query.options(
|
| |
+ joinedload(models.Build.build_chroots),
|
| |
+ joinedload(models.Build.package),
|
| |
+ joinedload(models.Build.copr),
|
| |
+ )
|
| |
+
|
| |
# WORKAROUND
|
| |
# We can't filter builds by status directly in the database, because we
|
| |
# use a logic in Build.status property to determine a build status.
|
| |
See PR#1914
I found two bottlenecks
1)
to_dict
function isn't extremely slow but it can be made fasterby pre-loading the
models.Build
relationships. This adds up andbrings a significant speedup for large projects
2) Querying the first pages is blazing fast but it gets 10 times
slower when approaching large offsets. We can mitigate the slowdown
by querying more results per page because the time for convering
database results to JSON remains the same but we simply don't have
to calculate the offset so often.
With this changes, I was able to reduce the time for completing
from ~42min to ~15min.