对于大数据量写入db时(如20-100万笔),多少笔commit一次 效率最高呢??
为什么??

解决方案 »

  1.   

    我知道的是 etl工具informatica的默认commit条数为:10000
    具体怎么样好看有高手知道不
    关注
      

  2.   

    理论上来说1次性提交的效率要高于分批提交,不过数据量太大的时候,回滚段会比较巨大,可能造成快照过旧,提交失败,所以根据你的实际情况来选择每次commit的条数。
      

  3.   

    根据TOM的建议,事务应该尽量长,而不是尽量短。这和3楼的说明是一致的,即所有的插入操作完成后只提交一次。
    下面引自Tom的Expert Oracle Database Architecture: 9i and 10g Programming Techniques and Solutions 
    Chapter 8 Transactions
    Bad Transaction Habits节Oracle takes the opposite approach. Transactions are always implicit, and there is no way
    to have an “autocommit” unless an application implements it (see the “Using Autocommit”
    section for more details). In Oracle, every transaction should be committed when it must and
    never before. Transactions should be as large as they need to be. Issues such as locks, blocking,
    and so on should not really be considered the driving forces behind transaction size—data
    integrity is the driving force behind the size of your transaction. Locks are not a scarce
    resource, and there are no contention issues between concurrent readers and writers of data.
    This allows you to have robust transactions in the database. These transactions do not have
    to be short in duration—they should be exactly as long as they need to be (but no longer).
    Transactions are not for the convenience of the computer and its software; they are to protect
    your data.