diff --git a/project_composer.install b/project_composer.install
index 52970efe618a0b0e0e4f1124a213eceec75a7597..309dca0944fd095032985b222cff8967898f8c25 100644
--- a/project_composer.install
+++ b/project_composer.install
@@ -145,42 +145,42 @@ function project_composer_schema() {
     'primary key' => array('provider_count_id'),
   );
 
-  $schema['project_composer_namespace_map'] = array(
+  $schema['project_composer_namespace_map'] = [
     'description' => 'Drupal package json metadata file information',
-    'fields' => array(
-      'map_id' => array(
+    'fields' => [
+      'map_id' => [
         'description' => 'Unique ID for a mapping.',
         'type' => 'serial',
         'unsigned' => TRUE,
         'not null' => TRUE,
-      ),
-      'project_nid' => array(
+      ],
+      'project_nid' => [
         'description' => 'The {node}.nid of the project node that includes this provider.',
         'type' => 'int',
         'unsigned' => TRUE,
         'not null' => TRUE,
-      ),
-      'project_name' => array(
+      ],
+      'project_name' => [
         'description' => 'The machine readable name of a project',
         'type' => 'varchar',
         'length' => 255,
         'not null' => TRUE,
         'default' => '',
-      ),
-      'component_name' => array(
+      ],
+      'component_name' => [
         'description' => 'The component name (module or theme)',
         'type' => 'varchar',
         'length' => 255,
         'not null' => TRUE,
         'default' => '',
-      ),
-      'package_namespace' => array(
+      ],
+      'package_namespace' => [
         'description' => 'The namespace used in the json metadata',
         'type' => 'varchar',
         'length' => 255,
         'not null' => TRUE,
         'default' => '',
-      ),
+      ],
       'category' => [
         'description' => 'The field_release_category, either “current” or “legacy”',
         'type' => 'varchar',
@@ -188,13 +188,15 @@ function project_composer_schema() {
         'not null' => TRUE,
         'default' => '',
       ],
-    ),
-    'primary key' => array('map_id'),
-    'indexes' => array(
-      'project_nid' => array('project_nid'),
+    ],
+    'primary key' => ['map_id'],
+    'indexes' => [
+      'project_nid' => ['project_nid'],
       'project_component_category' => ['project_name', 'component_name', 'category'],
-    ),
-  );
+      'category_namespace' => ['category', 'package_namespace'],
+    ],
+  ];
+
   $schema['project_composer_component'] = array(
     'description' => 'The component(s) contained by a project release.',
     'fields' => array(
@@ -1022,3 +1024,10 @@ function project_composer_update_7022() {
     'default' => 0,
   ]);
 }
+
+/**
+ * Add project_composer_namespace_map.category_namespace index.
+ */
+function project_composer_update_7023() {
+  db_add_index('project_composer_namespace_map', 'category_namespace', ['category', 'package_namespace']);
+}
diff --git a/project_composer.sa.inc b/project_composer.sa.inc
index 124e98c9555b949b4020cde41513d0041c4c2553..a26aa73d24448fdb41fb924ea7b6d0351aa7a59e 100644
--- a/project_composer.sa.inc
+++ b/project_composer.sa.inc
@@ -25,7 +25,7 @@ function project_composer_security_advisories($release_category) {
     }
 
     // Get project node IDs.
-    $project_nids = db_query("SELECT project_nid FROM {project_composer_providers} WHERE release_category = 'current' AND provider_type = 'package' AND provider_name IN (:names)", [
+    $project_nids = db_query("SELECT map.project_nid, map.map_id, min(dupe.map_id) FROM {project_composer_namespace_map} map INNER JOIN {project_composer_namespace_map} dupe ON dupe.category = map.category AND dupe.project_name = map.project_name WHERE map.category = 'current' AND map.package_namespace IN (:names) GROUP BY map.project_nid HAVING map.map_id = min(dupe.map_id) ORDER BY NULL", [
       ':names' => $names,
     ])->fetchCol();
     if (in_array('core', $names)) {