Ignite cursor.getAll()需要很长时间才能检索数据

时间:2017-05-31 08:30:42

标签: java apache caching ignite in-memory-database

我正在使用Ignite v2和Java。下面是我的点燃节点配置。

    CacheConfiguration<Long, MyClass> cacheCfg = new CacheConfiguration<Long, MyClass>();
    cacheCfg.setName("Test_CacheConfig");
    cacheCfg.setReadThrough(true);
    cacheCfg.setWriteThrough(true);
    cacheCfg.setIndexedTypes(Long.class, MyClass.class, Long.class, MyClass.class); 
// Two  fields of long datatype are indexed in pojo MyClass as @QuerySqlField(index=true) 
    cacheCfg.setCacheMode(CacheMode.PARTITIONED);

使用上述配置我创建cache as,

    IgniteCache<Long, MyClass> cache = ignite.getOrCreateCache(cacheCfg);

我有大量记录存储在此cache 约。 3500万

我在两个字段上查询cachefield1field2它们都在Myclass中编入索引。 理想情况下,查询只返回游标中的一条匹配记录。但是当我尝试使用cusror.getAll().get(0)从游标中读取记录时,大约需要4-5。在我的场景中,这太贵了。以下是我的查询代码

    SqlFieldsQuery sql = new SqlFieldsQuery(
"select *  from MyClass where field1 <= some value and maxIpVal >= some value ");
    //It returns only one record
    QueryCursor<List<?>> cursor = cache.query(sql);
    System.out.println(cursor.getAll().get(0)); // It takes time to fetch data

注意: 我使用cacheCacheStore中放置记录。记录总数约为3500万。我已按照此处的建议配置了JVM https://apacheignite.readme.io/docs/jvm-and-system-tuning  任何形式的帮助都将受到高度赞赏。

提前致谢。

1 个答案:

答案 0 :(得分:3)

您很可能需要包含两个字段的组索引:https://apacheignite.readme.io/docs/indexes#section-group-indexes

查看执行计划以检查使用的索引以及查询的执行方式也是一个好主意:https://apacheignite.readme.io/docs/sql-performance-and-debugging#using-explain-statement