• 请不要在回答技术问题时复制粘贴 AI 生成的内容
xiaofan2
V2EX  ›  程序员

JDBC 批量插入 oracle 很慢?

  •  
  •   xiaofan2 · Dec 19, 2020 · 2281 views
    This topic created in 2151 days ago, the information mentioned may be changed or developed.

    我们现在有两个库,一个 mysql,一个 oracle,都使用 jdbc NamedParameterJdbcTemplate.batchUpdate 插入,但是 mysql 插入 5W 条数据 3S 左右,Oracle 要 300S,不知道是哪个地方有问题?有没有大佬知道

    3 replies  •  2020-12-21 14:33:37 +08:00
    billlee
    billlee
    Dec 19, 2020
    1
    166/s, 盲猜是事务提交的问题?
    heavyrainn
    heavyrainn
    Dec 21, 2020
    2
    oracle 慢的话,按自己的经验,有两个点可以注意一下(针对 11g 版本)。一个是,oracle 在进行 batch 的时候记得先手动关闭 autoCommit,不然 batch 无效;另外一个是,手动调整一下 fetchsize,oracle 默认的 fetchsize 是 10,很小
    xiaofan2
    xiaofan2
    OP
    Dec 21, 2020
    3
    @billlee
    @heavyrainn 我测试了一下 感觉是事务的问题 然后还有个操作是在 insert 语句里面添加上 /*+APPEND_VALUES(t)*/ 这个语句 虽然我也不知道是咋起作用的 但是还真是有作用...
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4344 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 07:03 · PVG 15:03 · LAX 23:03 · JFK 02:03
    ♥ Do have faith in what you're doing.