* Jeremy Zawodny
> On Mon, Jan 21, 2002 at 05:18:35PM +0100, Roger Baklund wrote:
> > Hi,
> >
> > Also, I wonder what is the best order for my primary keys:
> >
> > a int        This is the 'main' id, very many distinct values
> > b tinyint    This is a source code, possible values are 1 or 2
> > c smallint   Some counter
> > d tinyint    Another counter
> >
> >   or
> >
> > b tinyint    This is a source code, possible values are 1 or 2
> > a int        This is the 'main' id, very many distinct values
> > c smallint   Some counter
> > d tinyint    Another counter
> >
> > Which will perform faster, when all lookups use both a and b?
>
> Is this helpful at all?

I don't understand...? Why would it not be?

>   http://www.linux-mag.com/2001-06/mysql_01.html
>
> It covers compound indexes (among other topics).

I have read this article earlier, and I read the part about compound indexes
again now, but I still don't understand why my compound index would not be
helpful...?

Just to make it clear: this is the primary key, and all four parts of the
index are needed to identify the row. Most of the time I use the three first
parts, sometimes I use all four parts, and sometimes I use only the first
two parts.

My question was: is it better to have the part with most distinct values
first, or is it better to have the part with very few distinct values first,
when _all_ queries _always_ use both parts?

I believe the answer to this depends on how the index is stored and handled
internally by mysql, and as I do not have this knowledge, I asked the
list...

I know both ways will work, but as I have rather large amounts of data and
speed is important in this application, I would like to do it the optimal
way.

Thank you for your time.  :o)

--
Roger


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to