عرض عملي: تقسيم سجل الطلبات حسب الشهر
في هذا الدرس 3 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
convert the order history to monthly partitions and observe pruning.
تفاصيل المخطط المبدئي
خطوة بخطوة
- Show the unpartitioned 10 M-row
ordersand the plan for a one-month query (large index or sequential scan). - Create the partitioned table
orders_pwith a composite primary key and monthly partitions plus a default partition. - Copy data in batches and add indexes; swap names in a short transaction.
- Run the one-month query:
EXPLAINshows only one partition scanned (pruning). - Planned mistake: filter with a function on
created_at, so pruning does not happen. Fix: use a direct range. DETACH PARTITION orders_2025_01and archive; compare with the old bulkDELETE.
Prepares MID-019-LAB1.
اختبر فهمك
What shows pruning in the plan?
أظهر الإجابة
Only the matching partitions appear as scan nodes.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.