Skip to content
Ameen Abozaid
Planned lessonMID-021-L06

Demo: 10× faster bulk updates with batching

  • Lesson 6 of 6
  • Mid-level
On This Lesson 3 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

speed up the nightly price update without leaving JPA.

Draft outline details

Step by step

  1. Baseline: load 100 000 products, change the price, saveAll; record statement count and time with statistics.
  2. Enable batch_size=50 and order_updates; measure again.
  3. Page through the data and flush() + clear() every 50 rows to keep memory stable.
  4. Planned mistake: batching is set but entities use IDENTITY and the job inserts; inserts stay unbatched. Fix: switch to a sequence for insert jobs (updates are not affected by IDENTITY).
  5. Compare final statement counts and elapsed time (target about 10× faster).
  6. Mention the alternative of one set-based UPDATE statement when entity logic is not needed.

Prepares MID-021-LAB1.

Check your understanding

What was the statement count change after batching?

Show answer

Many single-row statements became far fewer batched executions.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Type to search levels, phases, modules and lessons.