From be3d697dc4daca93f0c7ccd715e9e6d93ef0a1f7 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Thu, 19 May 2016 11:45:38 -0400 Subject: [PATCH] pgsql: remove unnecessary join used in GetNotification (#179) --- database/pgsql/queries.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/database/pgsql/queries.go b/database/pgsql/queries.go index aba20d70..f9373bb1 100644 --- a/database/pgsql/queries.go +++ b/database/pgsql/queries.go @@ -206,14 +206,13 @@ const ( searchNotificationLayerIntroducingVulnerability = ` SELECT l.ID, l.name - FROM Vulnerability v, Vulnerability_Affects_FeatureVersion vafv, FeatureVersion fv, Layer_diff_FeatureVersion ldfv, Layer l - WHERE v.id = $1 - AND v.id = vafv.vulnerability_id + FROM Vulnerability_Affects_FeatureVersion vafv, FeatureVersion fv, Layer_diff_FeatureVersion ldfv, Layer l + WHERE l.id >= $2 + AND vafv.vulnerability_id = $1 AND vafv.featureversion_id = fv.id - AND fv.id = ldfv.featureversion_id + AND ldfv.featureversion_id = fv.id AND ldfv.modification = 'add' AND ldfv.layer_id = l.id - AND l.id >= $2 ORDER BY l.ID LIMIT $3`