انتقل إلى المحتوى
أمين أبوزيد
درس مخطط لهJNR-034-L04

الفهارس (Indexes): نظرة أولى

  • الدرس 4 من 5
  • Junior
في هذا الدرس 4 موضوعات

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

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

في هذا الدرس

know what an index is and how to check it is used.

الموضوعات المخطط لها

  • An index is a sorted lookup structure (usually a B-tree) that makes searches fast, like a book's index.
  • It costs disk space and slows writes, so do not index every column.
  • PostgreSQL creates indexes for primary keys and unique constraints automatically, but not for foreign keys: index them yourself.
  • Index columns used in where, join, and order by for common queries.
  • EXPLAIN shows the plan: Seq Scan reads the whole table, Index Scan uses an index; EXPLAIN ANALYZE also runs the query and times it.
تفاصيل المخطط المبدئي

عرض عملي

sql
create index ix_order_line_order_id on order_line(order_id);
explain select * from order_line where order_id = 42;
-- expect: Index Scan using ix_order_line_order_id (on large tables)

اختبر فهمك

Does PostgreSQL index foreign key columns automatically?

أظهر الإجابة

No.

التطبيق

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

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

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

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