gpt4 book ai didi

java - Ignite cursor.getAll() 需要很长时间来检索数据

转载 作者:行者123 更新时间:2023-11-29 04:29:47 28 4
gpt4 key购买 nike

我在 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 作为,

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

我在这个缓存中存储了大量记录大约。 3500万

我在两个字段上查询此缓存field1field2 它们都在 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

注意:我使用 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

关于java - Ignite cursor.getAll() 需要很长时间来检索数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44279562/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com