انتقل إلى المحتوى
أمين أبوزيد
درس مخطط لهMID-013-L08

عرض عملي: تقدير خاطئ وكيف تصلحه الإحصائيات

  • الدرس 8 من 8
  • Mid-level
في هذا الدرس 3 موضوعات

هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

في هذا الدرس

diagnose a bad plan caused by a wrong row estimate.

تفاصيل المخطط المبدئي

خطوة بخطوة

  1. Create correlated columns (country, currency) and a query filtering on both; the planner estimates 5 rows, actual is 300 000.
  2. Show the nested loop chosen because of the underestimate and its runtime.
  3. Run CREATE STATISTICS s (dependencies) ON country, currency FROM orders; ANALYZE orders;.
  4. Planned mistake: forget to run ANALYZE after creating the statistics; the estimate does not change. Fix: analyze.
  5. Re-run: estimate close to actual, plan switches to a hash join, time drops.

اختبر فهمك

Why was the estimate wrong?

أظهر الإجابة

The planner assumed the two columns were independent.

التطبيق

طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.

المختبر والتمارين الاختبار

تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.

اكتب للبحث في المستويات والمراحل والوحدات والدروس.