From 1847845151cb4627b90aa5c41ad47c76f0b63e30 Mon Sep 17 00:00:00 2001 From: Viktor Lofgren Date: Sat, 4 Nov 2023 19:32:02 +0100 Subject: [PATCH] Revert "(loader) Optimize INSERT statements" This reverts commit 7cb92195d1e09a406791f87bccbb0518764aade0. --- .../loading/domains/DomainLoaderService.java | 31 ++++--------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/code/processes/loading-process/src/main/java/nu/marginalia/loading/domains/DomainLoaderService.java b/code/processes/loading-process/src/main/java/nu/marginalia/loading/domains/DomainLoaderService.java index 404b85cf..3ce30d96 100644 --- a/code/processes/loading-process/src/main/java/nu/marginalia/loading/domains/DomainLoaderService.java +++ b/code/processes/loading-process/src/main/java/nu/marginalia/loading/domains/DomainLoaderService.java @@ -45,42 +45,24 @@ public class DomainLoaderService { DomainIdRegistry ret = new DomainIdRegistry(); try (var conn = dataSource.getConnection(); - var existingDomainNamesQuery = conn.prepareStatement(""" - SELECT DOMAIN_NAME FROM EC_DOMAIN - """); var selectStmt = conn.prepareStatement(""" SELECT ID, DOMAIN_NAME FROM EC_DOMAIN WHERE DOMAIN_NAME=? """) ) { - Set existingDomainNames = new HashSet<>(); - var existingDomainNamesRs = existingDomainNamesQuery.executeQuery(); - while (existingDomainNamesRs.next()) { - existingDomainNames.add(new EdgeDomain(existingDomainNamesRs.getString(1))); - } try (var inserter = new DomainInserter(conn, nodeId)) { - for (var domainName : readSetDomainNames(inputData)) { - var domain = new EdgeDomain(domainName); - if (existingDomainNames.contains(domain)) - continue; - - inserter.accept(domain); - domainNamesAll.add(domainName); + for (var domain : readSetDomainNames(inputData)) { + inserter.accept(new EdgeDomain(domain)); + domainNamesAll.add(domain); } } try (var inserter = new DomainInserter(conn, -1)) { - for (var domainName : readReferencedDomainNames(inputData)) { - var domain = new EdgeDomain(domainName); - if (existingDomainNames.contains(domain)) - continue; - - inserter.accept(domain); - domainNamesAll.add(domainName); + for (var domain : readReferencedDomainNames(inputData)) { + inserter.accept(new EdgeDomain(domain)); + domainNamesAll.add(domain); } } - existingDomainNames.clear(); - try (var updater = new DomainAffinityUpdater(conn, nodeId)) { for (var domain : readSetDomainNames(inputData)) { updater.accept(new EdgeDomain(domain)); @@ -182,7 +164,6 @@ public class DomainLoaderService { statement.close(); } } - private static class DomainAffinityUpdater implements AutoCloseable { private final PreparedStatement statement; private final int nodeAffinity;