From 8a6c940aaf7d9d1fa5fe297aac3d7757c77caaea Mon Sep 17 00:00:00 2001 From: "Alexander v. Buchholtz" Date: Sat, 4 Jun 2016 23:36:43 +0200 Subject: [PATCH] Optimized CLEANUP_ORPHANS query for H2 1.4.x Original query from dbStatements.properties writes millions of records from subselect to file system due to MAX_MEMORY_ROWS Setting http://www.h2database.com/html/grammar.html?highlight=max_memory_rows&search=MAX_MEM#set_max_memory_rows Database maintenance task therefore takes forever. The new query (copied from postgresql) works way faster. --- .../src/main/resources/data/dbStatements_h2.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/dependency-check-core/src/main/resources/data/dbStatements_h2.properties b/dependency-check-core/src/main/resources/data/dbStatements_h2.properties index aea9f986a..59b4204c5 100644 --- a/dependency-check-core/src/main/resources/data/dbStatements_h2.properties +++ b/dependency-check-core/src/main/resources/data/dbStatements_h2.properties @@ -13,3 +13,4 @@ # limitations under the License. MERGE_PROPERTY=MERGE INTO properties (id, value) KEY(id) VALUES(?, ?) +CLEANUP_ORPHANS=DELETE FROM cpeEntry WHERE id IN (SELECT id FROM cpeEntry LEFT JOIN software ON cpeEntry.id = software.CPEEntryId WHERE software.CPEEntryId IS NULL)