From a4b4c031b438e254fa8870f1f786aa03aced93a1 Mon Sep 17 00:00:00 2001 From: Mustafa Gezen Date: Thu, 2 Feb 2023 15:22:22 +0100 Subject: [PATCH] Make compat query faster --- apollo/server/routes/api_compat.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apollo/server/routes/api_compat.py b/apollo/server/routes/api_compat.py index d8cc29a..cf3d908 100644 --- a/apollo/server/routes/api_compat.py +++ b/apollo/server/routes/api_compat.py @@ -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