The following program was used with and without indexes:
EmbeddedCacheManager ecm = new DefaultCacheManager("/Users/mmarkus/github/infinispan-xa-recovery-sample/src/main/resources/config.xml");
Cache<Object,Object> c = ecm.getCache();
int KEY_COUNT = 10000;
long start = System.currentTimeMillis();
for (int i = 0; i < KEY_COUNT; i++)
{
String s = key(i);
c.put(s, s);
}
long duration = System.currentTimeMillis() - start;
System.out.println("duration(millis) for " + KEY_COUNT + " writes = " + duration);
c.getAdvancedCache().getDataContainer().clear();
Set<String> result = new HashSet<String>();
start = System.currentTimeMillis();
for (int i = 0; i < KEY_COUNT; i++)
{
result.add((String) c.get(key(i)));
}
duration = System.currentTimeMillis() - start;
System.out.println("duration(millis) for " + KEY_COUNT + " reads = " + duration);
if (result.size() Unable to render embedded object: File (= KEY_COUNT) throw new RuntimeException("Huh?) not found.!");
start = System.currentTimeMillis();
for (int i = 0; i < KEY_COUNT; i++)
{
c.remove(key(i));
}
duration = System.currentTimeMillis() - start;
System.out.println("duration(millis) for " + KEY_COUNT + " removes = " + duration);
The indexed column was "idColumnName" - which is passed as param in all key-based ops (get, remove).
The underlaying database was postgresql 8.4. Same results were obtained with and without indexes. Looking at the generated table the "idColumnName" is marked as primary key, and gets automatically indexed when created. I expect most vendors to index the PK out of the box, so no point in doing any recommandation around indexing.
The following program was used with and without indexes:
EmbeddedCacheManager ecm = new DefaultCacheManager("/Users/mmarkus/github/infinispan-xa-recovery-sample/src/main/resources/config.xml");
Cache<Object,Object> c = ecm.getCache();
int KEY_COUNT = 10000;
{ String s = key(i); c.put(s, s); }long start = System.currentTimeMillis();
for (int i = 0; i < KEY_COUNT; i++)
long duration = System.currentTimeMillis() - start;
System.out.println("duration(millis) for " + KEY_COUNT + " writes = " + duration);
c.getAdvancedCache().getDataContainer().clear();
Set<String> result = new HashSet<String>();
{ result.add((String) c.get(key(i))); }start = System.currentTimeMillis();
for (int i = 0; i < KEY_COUNT; i++)
duration = System.currentTimeMillis() - start;
System.out.println("duration(millis) for " + KEY_COUNT + " reads = " + duration);
if (result.size() Unable to render embedded object: File (= KEY_COUNT) throw new RuntimeException("Huh?) not found.!");
start = System.currentTimeMillis();
{ c.remove(key(i)); }for (int i = 0; i < KEY_COUNT; i++)
duration = System.currentTimeMillis() - start;
System.out.println("duration(millis) for " + KEY_COUNT + " removes = " + duration);
The indexed column was "idColumnName" - which is passed as param in all key-based ops (get, remove).
The underlaying database was postgresql 8.4. Same results were obtained with and without indexes. Looking at the generated table the "idColumnName" is marked as primary key, and gets automatically indexed when created. I expect most vendors to index the PK out of the box, so no point in doing any recommandation around indexing.