Make compat query faster

This commit is contained in:
Mustafa Gezen 2023-02-02 15:22:22 +01:00
parent 0c2e29785a
commit a4b4c031b4
Signed by untrusted user who does not match committer: mustafa
GPG Key ID: DCDF010D946438C1
1 changed files with 2 additions and 1 deletions

View File

@ -161,6 +161,7 @@ async def fetch_advisories_compat(
count(a.*) over () as total
from
advisories a
left outer join advisory_affected_products ap on ap.advisory_id = a.id
left outer join advisory_cves c on c.advisory_id = a.id
left outer join advisory_fixes f on f.advisory_id = a.id
where
@ -173,7 +174,7 @@ async def fetch_advisories_compat(
and ((select severity from vars) is null or a.severity = (select severity from vars))
and ((select kind from vars) is null or a.kind = (select kind from vars))
and ((select search from vars) is null or
exists (select name from advisory_affected_products where advisory_id = a.id and name like '%' || (select product from vars) || '%') or
ap.name like '%' || (select product from vars) || '%' or
a.synopsis ilike '%' || (select search from vars) || '%' or
a.description ilike '%' || (select search from vars) || '%' or
exists (select cve from advisory_cves where advisory_id = a.id and cve ilike '%' || (select search from vars) || '%') or