From 86b1926d7cfd5cbcddecce72327c78a656073229 Mon Sep 17 00:00:00 2001 From: Tomas Touceda Date: Wed, 20 Oct 2021 13:24:51 -0300 Subject: [PATCH] Add missing join condition (#2586) --- changes/add-join-condition | 1 + server/datastore/mysql/software.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changes/add-join-condition diff --git a/changes/add-join-condition b/changes/add-join-condition new file mode 100644 index 0000000000..26848028dd --- /dev/null +++ b/changes/add-join-condition @@ -0,0 +1 @@ +* Improve performance of software listing query. diff --git a/server/datastore/mysql/software.go b/server/datastore/mysql/software.go index 3eeb50116a..46f9e9317a 100644 --- a/server/datastore/mysql/software.go +++ b/server/datastore/mysql/software.go @@ -236,7 +236,7 @@ func listSoftwareDB(ctx context.Context, q sqlx.QueryerContext, hostID *uint, te SELECT DISTINCT s.id, scv.cve FROM host_software hs JOIN hosts h ON (hs.host_id=h.id) - JOIN software s + JOIN software s ON (s.id=hs.software_id) JOIN software_cpe scp ON (s.id=scp.software_id) JOIN software_cve scv ON (scp.id=scv.cpe_id) WHERE %s AND %s