RE: [nyphp-talk] Table Indexes

2008-09-28 Thread Hans Zaunere
> > 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. > > I think I'm starting to under

Re: [nyphp-talk] Table Indexes

2008-09-28 Thread Michael B Allen
On Sun, Sep 28, 2008 at 3:02 PM, Hans Zaunere <[EMAIL PROTECTED]> wrote: >> > 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 manu

RE: [nyphp-talk] Table Indexes

2008-09-28 Thread Hans Zaunere
> > 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 >

Re: [nyphp-talk] Table Indexes

2008-09-28 Thread Daniel Convissor
On Sat, Sep 27, 2008 at 08:54:10PM -0400, Michael B Allen wrote: > > 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 mult

Re: [nyphp-talk] Table Indexes

2008-09-27 Thread Michael B Allen
On Sat, Sep 27, 2008 at 8:32 PM, Daniel Convissor <[EMAIL PROTECTED]> wrote: > Hi John: > > On Sun, Sep 07, 2008 at 02:31:48PM -0400, John Campbell wrote: >> >> With MySQL the fastest is often: >> Primary(a,b) >> index(b) > > I agree. > > >> And in sometimes you even want: >> Primary(a,b) >> index(

Re: [nyphp-talk] Table Indexes

2008-09-27 Thread Daniel Convissor
Hi John: On Sun, Sep 07, 2008 at 02:31:48PM -0400, John Campbell wrote: > > With MySQL the fastest is often: > Primary(a,b) > index(b) I agree. > And in sometimes you even want: > Primary(a,b) > index(a) > index(b) The second index of "a" would duplicate the index of "a" in the primary key.

Re: [nyphp-talk] Table Indexes

2008-09-07 Thread John Campbell
> Can anyone recommend which method I should try first? Don't create the auto increment pk, as it is unnecessary. With MySQL the fastest is often: Primary(a,b) index(b) And in sometimes you even want: Primary(a,b) index(a) index(b) I think mysql treats primary key pairs as a simple concatenat

[nyphp-talk] Table Indexes

2008-09-07 Thread Michael B Allen
I need a table that will be used basically as a map between records in another table and I'm not sure how to create the indexes. At first I thought I would just do something like: CREATE TABLE map ( id int(5) unsigned NOT NULL AUTO_INCREMENT, a int(5) unsigned NOT NULL, b int(