diff --git a/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/MariadbPersistenceManager.java b/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/MariadbPersistenceManager.java index 984dd2c99..196a035a2 100644 --- a/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/MariadbPersistenceManager.java +++ b/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/MariadbPersistenceManager.java @@ -141,6 +141,8 @@ static final Moment parseMoment(String value) { private DSLContext dslContext; private String schemaPriority; + private final Map> tableCache = new HashMap<>(); + /** * Tracker for the amount of data fetched form the DB by this PM. */ @@ -708,6 +710,10 @@ public Table getDbTable(String tableName) { @Override public Table getDbTable(Name tableName) { + return tableCache.computeIfAbsent(tableName, (t) -> readDbTableFromDb(tableName)); + } + + public Table readDbTableFromDb(Name tableName) { final Meta meta = dslContext.meta(); final List> tables = meta.getTables(tableName); if (tables.isEmpty()) { diff --git a/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/PostgresPersistenceManager.java b/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/PostgresPersistenceManager.java index b4d8fc782..9914f65a0 100644 --- a/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/PostgresPersistenceManager.java +++ b/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/PostgresPersistenceManager.java @@ -141,6 +141,8 @@ static final Moment parseMoment(String value) { private DSLContext dslContext; private String schemaPriority; + private final Map> tableCache = new HashMap<>(); + /** * Tracker for the amount of data fetched form the DB by this PM. */ @@ -703,6 +705,10 @@ public Table getDbTable(String tableName) { @Override public Table getDbTable(Name tableName) { + return tableCache.computeIfAbsent(tableName, (t) -> readDbTableFromDb(tableName)); + } + + public Table readDbTableFromDb(Name tableName) { final Meta meta = dslContext.meta(); final List> tables = meta.getTables(tableName); if (tables.isEmpty()) {