Improve insert performance massively

后端 未结 2 1373
误落风尘
误落风尘 2021-01-04 17:55

In my application I need to massively improve insert performance. Example: A file with about 21K records takes over 100 min to insert. There are reasons it can takes some ti

相关标签:
2条回答
  • 2021-01-04 18:46

    sounds like a database problem. check your tables if they use InnoDB or MyISAM, the latter is in my experience very slow with insert and is the default for new dbs. remove foreign keys as far as you can

    If your problem really is related to a single unique index InnoDB could do the trick.

    0 讨论(0)
  • 2021-01-04 18:51

    see

    spring-data JPA: manual commit transaction and restart new one

    Add entityManager.flush() and entityManager.clear() after every n-th call to save() method. If you use hibernate add hibernate.jdbc.batch_size=100 which seems like a reasonable choice.

    Performance increase was > 10x, probably close to 100x.

    0 讨论(0)
提交回复
热议问题