【问题标题】:Apache Ignite SqlFieldsQuery cursor issueApache Ignite SqlFieldsQuery 游标问题
【发布时间】:2016-11-17 11:30:15
【问题描述】:

我正在使用 SqlFieldsQuery 缓存约 1_000_000 行。

QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery("select num from some_cache"))

我已经阅读了有关查询游标惰性的内容 (http://apacheignite.gridgain.org/docs/cache-queries#section-querycursor)。但似乎缓存中的所有数据都是一次加载的。因为我的查询需要很长时间,并且 cursor.getAll() 会立即返回包含所有数据的集合。

这是缺少某些配置还是预期的行为?

【问题讨论】:

    标签: java sql caching ignite


    【解决方案1】:

    getAll 确实一次返回所有行。

    QueryCursor 扩展 Iterable,使用迭代器来利用惰性。

    QueryCursor<List> cursor = cache.query(new SqlFieldsQuery("select num from some_cache"))
    for (List l : cursor)
        doSomething(l);
    

    【讨论】:

    • 我使用getAll 只是为了测试数据是否已经加载。我想说在cache.query期间似乎所有数据都已经加载(没有调用getAll
    • 好吧,看起来查询比结果检索花费的时间更多。这并不意味着延迟加载不起作用。
    猜你喜欢
    • 1970-01-01
    • 2021-03-06
    • 2022-06-10
    • 1970-01-01
    • 1970-01-01
    • 2019-01-16
    • 2021-10-03
    • 2022-08-15
    • 2020-06-29
    相关资源
    最近更新 更多