[英]Ignite cursor.getAll() takes very long time to retrieve data
I am using Ignite v2 with Java. 我正在使用Ignite v2和Java。 Below is my ignite node configuration. 下面是我的点燃节点配置。
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);
Using above configuration I am creating cache
as, 使用上面的配置我创建cache
为,
IgniteCache<Long, MyClass> cache = ignite.getOrCreateCache(cacheCfg);
I have a large number of records stored in this cache
approx. 我在此cache
存储了大量记录。 35 million . 3500万 。
I am querying this cache
on two fields. 我在两个字段上查询此cache
。 field1
and field2
they both are indexed in Myclass. field1
和field2
它们都在Myclass中编入索引。 Ideally, the query returns only one matching record in the cursor. 理想情况下,查询只返回游标中的一个匹配记录。 But when I try the read the record from the cursor using cusror.getAll().get(0)
it takes around 4-5. 但是当我尝试使用cusror.getAll().get(0)
从游标中读取记录时, cusror.getAll().get(0)
大约需要4-5。 This is way too much expensive in my scenario. 在我的场景中,这太贵了。 Below is my query code 以下是我的查询代码
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
Note: I am putting records in cache
using CacheStore
. 注意:我使用CacheStore
将记录放在cache
中。 The total number of records are approximately 35 million. 记录总数约为3500万。 I have already configured JVM as recommended here https://apacheignite.readme.io/docs/jvm-and-system-tuning 我已按照此处的建议配置了JVM https://apacheignite.readme.io/docs/jvm-and-system-tuning
Most likely you need a group index with both fields: https://apacheignite.readme.io/docs/indexes#section-group-indexes 很可能你需要一个包含两个字段的组索引: https : //apacheignite.readme.io/docs/indexes#section-group-indexes
It is also always a good idea to look at execution plan to check what indexes are used and how the query is executed: https://apacheignite.readme.io/docs/sql-performance-and-debugging#using-explain-statement 查看执行计划以检查使用的索引以及查询的执行方式也是一个好主意: https : //apacheignite.readme.io/docs/sql-performance-and-debugging#using-explain-statement
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.