MySQL + SQL · Lesson 90

MySQL में Composite Index

Composite Index क्या है?

Composite index दो या ज़्यादा columns को एक साथ cover करता है। यह उन columns पर क्रम से filter करने वाली queries तेज़ करता है।

Example

CREATE INDEX idx_class_marks ON students(class, marks);

-- यह query index अच्छे से use करती है
SELECT * FROM students WHERE class = '10' AND marks >= 80;

Column Order ज़रूरी है

(class, marks) पर composite index, class या class+marks से filter करती queries में मदद करता है — पर सिर्फ marks से filter में नहीं। सबसे बायाँ column use होना चाहिए।

सारांश

  • Composite index कई columns पर फैला होता है।
  • Column order ज़रूरी — सबसे बायाँ column filter में होना चाहिए।
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

💻 लाइव कोड एडिटर

इस पेज के प्रोग्राम यहीं तैयार हैं — चलाएँ, बदलें और सीखें। कुछ भी इंस्टॉल किए बिना।
OneCompiler द्वारा संचालित। कोड एडिटर में अपने आप आ जाता है — Run दबाकर आउटपुट देखें। अगर एडिटर न खुले तो नए टैब में खोलें.