Java Ignite cursor.getAll()检索数据需要很长时间
我将Ignite v2与Java一起使用。下面是我的ignite节点配置Java Ignite cursor.getAll()检索数据需要很长时间,java,caching,ignite,in-memory-database,Java,Caching,Ignite,In Memory Database,我将Ignite v2与Java一起使用。下面是我的ignite节点配置 CacheConfiguration<Long, MyClass> cacheCfg = new CacheConfiguration<Long, MyClass>(); cacheCfg.setName("Test_CacheConfig"); cacheCfg.setReadThrough(true); cacheCfg.setWriteThr
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);
我在这个缓存中存储了大量记录
大约3500万条
我正在两个字段上查询此缓存<代码>字段1和字段2都在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
SqlFieldsQuery sql=newsqlfieldsquery(
“从MyClass中选择*,其中field1=某个值”);
//它只返回一条记录
QueryCursor很可能需要一个包含两个字段的组索引:
查看执行计划以检查使用了哪些索引以及查询是如何执行的也是一个好主意:谢谢,我在上面的链接中指定了索引和其他更改,这大大提高了我的性能。现在是1秒,而之前是3-4秒。然而,我们期望的性能标准是1-10毫秒。ApacheRedis似乎遇到了他们,我想知道Ignite不会那么快。1秒听起来太慢了,特别是当查询确实返回一个条目时。看看执行计划,看看那里发生了什么。另外,不要忘记做热身——在进行测量之前,在循环中多次运行查询。JVM JIT编译器需要一些时间来完成所有的优化,然后才能开始获得最佳结果。是的,没错,我正要提到这一点。在加热JVM几次之后,我用“Explain”关键字打印了查询计划,只花了0-1毫秒。但是,从游标获取记录仍需要0-150毫秒。考虑到查询只返回一条记录,150毫秒也有点慢。你能在GitHub上创建一个小项目来重现这个问题吗?
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