From f2cfedf4c9f3a471df1616c7041ca33011a2ee87 Mon Sep 17 00:00:00 2001 From: Fuzzlemann Date: Thu, 3 Aug 2017 11:56:07 +0200 Subject: [PATCH] Remove unnecessary .stream() call Add setAutoCommit(false) at the SQLite connection; Improves speed massively --- .../java/com/djrapitops/plan/database/databases/SQLiteDB.java | 4 +++- .../com/djrapitops/plan/database/tables/GMTimesTable.java | 2 +- .../com/djrapitops/plan/database/tables/SessionsTable.java | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLiteDB.java b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLiteDB.java index 6b07d0bec..830de2d74 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLiteDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLiteDB.java @@ -50,7 +50,9 @@ public class SQLiteDB extends SQLDB { try { Class.forName("org.sqlite.JDBC"); - return DriverManager.getConnection("jdbc:sqlite:" + new File(plugin.getDataFolder(), dbName + ".db").getAbsolutePath()); + Connection connection = DriverManager.getConnection("jdbc:sqlite:" + new File(plugin.getDataFolder(), dbName + ".db").getAbsolutePath()); + connection.setAutoCommit(false); + return connection; } catch (ClassNotFoundException | SQLException e) { return null; } diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/GMTimesTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/GMTimesTable.java index 58c7e8437..0af21a887 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/GMTimesTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/GMTimesTable.java @@ -298,7 +298,7 @@ public class GMTimesTable extends Table { List>> batches = DBUtils.splitIntoBatchesWithID(gmTimes); - batches.stream().forEach(batch -> { + batches.forEach(batch -> { try { addNewGMTimesBatch(batch); } catch (SQLException e) { diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java index a5b4e609e..dc77351ae 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java @@ -218,7 +218,7 @@ public class SessionsTable extends Table { List>> batches = splitIntoBatches(sessions); - batches.stream().forEach(batch -> { + batches.forEach(batch -> { try { saveSessionBatch(batch); } catch (SQLException e) {