【问题标题】:Performance comparison between the different use of IgniteCache.loadCache不同使用IgniteCache.loadCache之间的性能比较
【发布时间】:2016-12-22 07:57:42
【问题描述】:

我正在使用 IgniteCache.loadCache 通过 RDMS 和 Ignite 集成将数据从 Oracle 加载到 Ignite Cache(https://apacheignite-mix.readme.io/v1.7/docs/automatic-persistence)

我的主类将启动客户端模式 Ignite,并将数据写入 3 个节点的 Ignite 集群。

以下是查询同一张表不同条件的sql数组

String[] sqlArray = new String[]{
 "select * from PERSON where id >=0 and id < 10000",
  "select * from PERSON where id >=10000 and id < 20000",
  ..
 "select * from PERSON where id >=10000000 and id < 10010000",

}

有两个选项可以运行这些 sql:

  1. 第一个选项是自己使用线程池:

    for (int i = 0; i< sqlArray.length; i++) { //submit the load through thread pool ThreadPool.submit(new Runnable() { cache.loadCache(null, Integer.class.getName(), sqlArray[i]) } }

  2. 第二个选项是:

    cache.loadCache(null, sqlArray)

从性能上我会问,哪一个会更快,或者它们在性能上不会有显着差异?

【问题讨论】:

    标签: ignite


    【解决方案1】:

    第二种方式看起来是正确的,因为loadCache 也被用于启动LoadCacheCustomQueryWorker 的线程池,并且您在每个查询中都节省了几个 ignite 计算调用。

    注意:请注意这些论点。您案例中的有效参数列表是:

    Object[] args = new Object[] {
        Integer.class.getName(),
        "select * from PERSON where id >=0 and id < 10000",
        Integer.class.getName(),
        "select * from PERSON where id >=10000 and id < 20000",
        Integer.class.getName(),
        "select * from PERSON where id >=10000000 and id < 10010000"
    }
    

    因此,参数计数必须是偶数。第一个参数是key type,第二个参数是SQL query

    【讨论】:

    • 谢谢@Taras。感谢API使用的提醒。根据我的观察,选项2比选项1快,我只是想知道为什么会在幕后发生这种情况。
    猜你喜欢
    • 2011-03-05
    • 2019-03-25
    • 1970-01-01
    • 2015-11-26
    • 2011-12-16
    • 2010-12-02
    • 1970-01-01
    • 2020-10-12
    • 1970-01-01
    相关资源
    最近更新 更多