From a4cbfdbe02af5a9842d35e7bfebd0a9fa566e44f Mon Sep 17 00:00:00 2001
From: Johannes Mey <johannes.mey@tu-dresden.de>
Date: Thu, 7 Feb 2019 15:10:26 +0100
Subject: [PATCH] keep index if no lookups AND no inserts occur. @kissinger is
 this a good idea?

---
 .../st/mquat/eris/coupling/ERISConnector.java | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/jastadd-mquat-eris/src/main/java/de/tudresden/inf/st/mquat/eris/coupling/ERISConnector.java b/jastadd-mquat-eris/src/main/java/de/tudresden/inf/st/mquat/eris/coupling/ERISConnector.java
index e695c8a..06b53fd 100644
--- a/jastadd-mquat-eris/src/main/java/de/tudresden/inf/st/mquat/eris/coupling/ERISConnector.java
+++ b/jastadd-mquat-eris/src/main/java/de/tudresden/inf/st/mquat/eris/coupling/ERISConnector.java
@@ -273,14 +273,14 @@ public class ERISConnector {
             // get the new config
             ERISLPConfiguration newDOrOConfig = currentDOrIConfigs.get(attribute);
 
-            ERISAttributeStatistics as = livingPartition.getAttributeStatistics(attribute);
+            ERISAttributeStatistics attributeStatistics = livingPartition.getAttributeStatistics(attribute);
             logger.debug("      attribute {}:", attribute.getName());
             logger.debug("        stats: lookups: {} inserts: {} scans: {} links: {} count: {}",
-                as.getLookups(),
-                as.getInserts(),
-                as.getScans(),
-                as.getLinks(),
-                as.getCount());
+                attributeStatistics.getLookups(),
+                attributeStatistics.getInserts(),
+                attributeStatistics.getScans(),
+                attributeStatistics.getLinks(),
+                attributeStatistics.getCount());
 
             // get the old config for the same attribute (if there is one)
             Optional<ERISLPConfiguration> oldConfig = livingPartition.getConfigForAttribute(attribute, false);
@@ -342,6 +342,13 @@ public class ERISConnector {
               } else {
                 logger.debug("        do NOT create an index {} to get an (index-) objective of {} (compared to {} without an index)", newIndexConfig, indexScore, lookupScoreWithoutIndex);
               }
+            } else {
+              // TODO this is our guess, but it seems reasonable to not get rid of an index if it causes no harm
+              // if there are no inserts, keep a potentially existing index
+              if (attributeStatistics.getInserts() == 0) {
+                // see if there is an index for the current attribute
+                livingPartition.getConfigForAttribute(attribute, true).ifPresent(configsToUse::add);
+              }
             }
           }
         }
-- 
GitLab