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