zoukankan      html  css  js  c++  java
  • Phoenix安装批次提交插入更新语句

    1 贴一下官方的代码

    https://phoenix.apache.org/tuning_guide.html

    try (Connection conn = DriverManager.getConnection(url)) {
      conn.setAutoCommit(false);
      int batchSize = 0;
      int commitSize = 1000; // number of rows you want to commit per batch.  
      try (Statement stmt = conn.prepareStatement(upsert)) {
        stmt.set ... while (there are records to upsert) {
          stmt.executeUpdate(); 
          batchSize++; 
          if (batchSize % commitSize == 0) { 
            conn.commit(); 
          } 
       } 
     conn.commit(); // commit the last batch of records 
     }
    

      

    2 解读代码

      之前是没1000条,提交一次,但是不足1000的,会在循环结束后的代码的最后一次commit()中被提交,所以也不会丢失提交代码。

  • 相关阅读:
    UVA-1595 Symmetry
    UVA-10763 Foreign Exchange
    剑指Offer
    剑指Offer
    剑指Offer
    剑指Offer
    剑指Offer
    剑指Offer
    剑指Offer
    剑指Offer
  • 原文地址:https://www.cnblogs.com/QuestionsZhang/p/11606382.html
Copyright © 2011-2022 走看看