Just make sure you have a key on any field you do a query on. Given that
there isn't a whole lot of correlation between your columns (logically
speaking.. ie, age doesn't really match up with city) I wouldn't worry
about compound keys.. they'll actually just slow you down since you need
to maintain larger keys that don't offer much advantage.  The only
exception to this might be if you commonly have a query which takes the
form you can represent with a compound key (ie.. you always grab a row by
age and city).. but, even then I don't think you will gain much over two
individual keys.

Take care,
seth

On Fri, 22 Jun 2001, Jaime Teng wrote:

> >> whats the difference between:
> >> alter table tablename add index (name);
> >> alter table tablename add index (age);
> >> alter table tablename add index (birthdate);
> >> alter table tablename add index (city);
> >
> >These are four INDIVIDUAL keys.. helpful if you want to search by name,
> >age, birthday, _OR_ city
>
> Will I get any performance if I were to do some complex
> query like:
>
> select * from tablename where name = 'BILL' and city = 'new york';
> select * from tablename where age > 30 and city = 'seatle';
> select * from tablename where age > 30 and name = 'JOHN';
>
> or do you suggest that I add the following on top of the
> previous index?
> alter table tablename add index (name,city);
> alter table tablename add index (age,city);
> alter table tablename add index (age,name);
> etc...
>
> thanks
> Jaime
>
>
>
> database,mysql
>
>

---
Seth Northrop
Manager of Information Technology
Reflectivity, Inc.
3910 Freedom Circle, Suite 103
Santa Clara, CA 95054
voice:  408-970-8881 x147
fax:    408-970-8840
http://www.reflectivity.com/


---------------------------------------------------------------------
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