عرض عملي: تحديثات جماعية أسرع 10 مرات بالدفعات
في هذا الدرس 3 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
speed up the nightly price update without leaving JPA.
تفاصيل المخطط المبدئي
خطوة بخطوة
- 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.
اختبر فهمك
What was the statement count change after batching?
أظهر الإجابة
Many single-row statements became far fewer batched executions.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.