mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix(rpc): improve type=search performance
This patch brings in the use of .with_entities on our RPC search query. This primarily fixes performance issues we were seeing with large queries. That being said, we do see a bit of a slowdown on large record count rpc queries, but it's quite negligible at this point. We still do aim to perform better than the older PHP implementation, so this is not a finishing patch by any means. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
d31a51742b
commit
b4495a49bf
2 changed files with 45 additions and 28 deletions
|
@ -1,6 +1,6 @@
|
|||
from sqlalchemy import and_, case, or_, orm
|
||||
|
||||
from aurweb import db, models, util
|
||||
from aurweb import db, models
|
||||
from aurweb.models import Package, PackageBase, User
|
||||
from aurweb.models.dependency_type import CHECKDEPENDS_ID, DEPENDS_ID, MAKEDEPENDS_ID, OPTDEPENDS_ID
|
||||
from aurweb.models.package_comaintainer import PackageComaintainer
|
||||
|
@ -257,8 +257,10 @@ class RPCSearch(PackageSearch):
|
|||
# Fix-up inherited search_by_cb to reflect RPC-specific by params.
|
||||
# We keep: "nd", "n" and "m". We also overlay four new by params
|
||||
# on top: "depends", "makedepends", "optdepends" and "checkdepends".
|
||||
util.apply_all(RPCSearch.keys_removed,
|
||||
lambda k: self.search_by_cb.pop(k))
|
||||
self.search_by_cb = {
|
||||
k: v for k, v in self.search_by_cb.items()
|
||||
if k not in RPCSearch.keys_removed
|
||||
}
|
||||
self.search_by_cb.update({
|
||||
"depends": self._search_by_depends,
|
||||
"makedepends": self._search_by_makedepends,
|
||||
|
@ -266,6 +268,9 @@ class RPCSearch(PackageSearch):
|
|||
"checkdepends": self._search_by_checkdepends
|
||||
})
|
||||
|
||||
# We always want an optional Maintainer in the RPC.
|
||||
self._join_user()
|
||||
|
||||
def _join_depends(self, dep_type_id: int) -> orm.Query:
|
||||
""" Join Package with PackageDependency and filter results
|
||||
based on `dep_type_id`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue