我正在使用Java使用IGNITE V2。以下是我的点火节点配置。
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万。
我在两个字段上查询此cache
。field1
和field2
它们都在myclass中索引。理想情况下,查询仅返回光标中的一个匹配记录。,但是当我使用cusror.getAll().get(0)
从光标读取记录时,查询仅返回一个匹配记录。在我的情况下,这太贵了。以下是我的查询代码
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万。我已经按照此处的建议配置JVMhttps://apacheignite.readme.io/docs/jvm-and-system-tuning
很可能需要两个字段的组索引:https://apacheignite.readme.io.io/docs/indexes#section #section group-indexes
查看执行计划也总是一个好主意解释说明