[英]Ignite cursor.getAll() takes very long time to retrieve data
我正在使用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
为,
IgniteCache<Long, MyClass> cache = ignite.getOrCreateCache(cacheCfg);
我在此cache
存储了大量记录。 3500万 。
我在两个字段上查询此cache
。 field1
和field2
它们都在Myclass中编入索引。 理想情况下,查询只返回游标中的一个匹配记录。 但是当我尝试使用cusror.getAll().get(0)
从游标中读取记录时, 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
注意:我使用CacheStore
将记录放在cache
中。 记录总数约为3500万。 我已按照此处的建议配置了JVM https://apacheignite.readme.io/docs/jvm-and-system-tuning
很可能你需要一个包含两个字段的组索引: https : //apacheignite.readme.io/docs/indexes#section-group-indexes
查看执行计划以检查使用的索引以及查询的执行方式也是一个好主意: https : //apacheignite.readme.io/docs/sql-performance-and-debugging#using-explain-statement
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.