Demo: 10× faster bulk updates with batching
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
- Baseline: load 100 000 products, change the price,
saveAll; record statement count and time with statistics. - Enable
batch_size=50andorder_updates; measure again. - Page through the data and
flush()+clear()every 50 rows to keep memory stable. - Planned mistake: batching is set but entities use
IDENTITYand the job inserts; inserts stay unbatched. Fix: switch to a sequence for insert jobs (updates are not affected byIDENTITY). - Compare final statement counts and elapsed time (target about 10× faster).
- Mention the alternative of one set-based
UPDATEstatement 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.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.