Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-877

analyse, document and suggest indexing the JDBC cache store

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

      Adding indexes to the JDBC cache store's backend table can drastically increase performance especially for the JdbcStringBasedCacheStore and partially for the JdbcMixedCacheStore.
      Investigate weather indexes can be defined through Jdbc in a portable manner (same way the tables are created on startup) or at least update documentation to describe how indexes should be defined and the advantages of having them defined.

            [ISPN-877] analyse, document and suggest indexing the JDBC cache store

            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.

            Mircea Markus (Inactive) added a comment - 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.

            Mircea Markus (Inactive) added a comment - http://community.jboss.org/message/587257#587257

            Moving to next release.

            Galder Zamarreño added a comment - Moving to next release.

              mircea.markus Mircea Markus (Inactive)
              mircea.markus Mircea Markus (Inactive)
              Archiver:
              rhn-support-adongare Amol Dongare

                Created:
                Updated:
                Resolved:
                Archived: