Help, PreparedBatch bulk inserts (~400) running too slow for production app

57 views
Skip to first unread message

Nicholas Roberson

unread,
Feb 12, 2021, 6:23:54 PM2/12/21
to jDBI
We are using a PreparedBatch to insert roughly 400 rows into a database and the current runtime is roughly 200ms. 

Our service SLA agreement is much lower than that however. Can anyone provide ideas on how to speed up bulk inserts into a database using JDBI? 

Here is a small snipped of our code: 

PreparedBatch insertStates = handle.prepareBatch(STATE_INSERT_WITH_ID);
insertStates.forEach(
    resourceState -> {
        insertParentStateBatch
             .bindBean(resourceState).add();
insertStates.execute()

Really simple but I am wondering if anyone has an idea of how this SQL is compiled and can help me speed up this transaction. 

Steven Schlansker

unread,
Feb 25, 2021, 3:01:27 PM2/25/21
to jd...@googlegroups.com

Hi Nicholas,

It's difficult for us to know exactly where the problem is just from what you've provided.
You could try to use your SQL database's EXPLAIN ANALYZE or equivalent,
or if the problem is in the Java code a profiler would help identify where time is being spent.

Best,
Steven
> Disclaimer
>
> The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.
>
> This email has been scanned for viruses and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business. Providing a safer and more useful place for your human generated data. Specializing in; Security, archiving and compliance. To find out more Click Here.
>
>
> --
> You received this message because you are subscribed to the Google Groups "jDBI" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jdbi+uns...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jdbi/f885982e-05cc-4950-a642-b71a353d93f9n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages