NYCPHP Meetup

NYPHP.org

[nycphp-talk] Table Indexes

Hans Zaunere lists at zaunere.com
Sun Sep 28 15:02:44 EDT 2008


> > So is the first column of a primary key always also an index? I
> > thought I read somewhere that the columns are concatenated together to
> > form one index?
> 
> I don't think they're actually concatenated.  The manual says:
> 
>    A multiple-column index can be _considered_ a sorted array
>    containing values that are created by concatenating the values
>    of the indexed columns.
> 
> Emphasis on "considered" is mine.  However MySQL stores it, the engine
> has the ability to utilize it.  More information (and the quote above)
> are from
> http://dev.mysql.com/doc/refman/5.0/en/multiple-column-indexes.html

It's all about what's available left-to-right.  MySQL can't - still AFAIK -
use parts of an index that are not sequential when using it left-to-right.
See:

http://dev.mysql.com/doc/refman/5.0/en/mysql-indexes.html

And use EXPLAIN a lot.

H





More information about the talk mailing list