index એ એક અલગ, sorted data structure છે (InnoDB માં B-tree) જે MySQL ને આખા table ને scan કર્યા વગર rows શોધવા દે છે. તેના વગર, lookup દરેક row વાંચે છે (એક full table scan); તેની સાથે, તે થોડા જ steps માં tree ને ચાલે છે.
Primary vs secondary
InnoDB માં table પોતે જ primary key index છે — એક clustered index. Rows ભૌતિક રીતે primary-key ના ક્રમમાં સંગ્રહાય છે, તેથી primary key lookup સીધું આખા row પર પહોંચે છે.
એ બીજા column(s) પર keyed થયેલો અલગ B-tree છે. તેના leaf nodes indexed value ઉપરાંત સંગ્રહે છે, તેથી secondary index વાપરવાનો ખર્ચ ઘણી વાર બીજા lookup ("clustered index પર પાછા જવું") નો હોય છે જેથી બાકીનો row મેળવી શકાય.
