Page is a not externally linkable
BCMG_Scott - 4:11 pm on May 30, 2003 (gmt 0)
First, according to MySQL docs the char vs varchar field does some funky things. If you try and set a field as char(20) it will "silently" change it to varchar(20). Conversely, if you try and set a field to varchar(2) it will set it to char(2). See 6.5.3.1 Silent Column Specification Changes of the MySQL doc for more information. On the surface this would seem logical and correct, it could be wrong though. Let's say you only have one SELECT query that you ever use: select col1, col2, col3, col4 should you create indexes on col1, col2 and col3 (thus creating 3 indexes)? NO. You will have 2 unused indexes taking up space. As you noted a query can only use one index at a time. So the better choice is to figure out how your select queries will be using indexes and which indexes each will use. Scott
dkubb, some good points. I have to add a couple items (and perhaps a correction). Make sure you index any fields you're querying in the WHERE clause
from table
where col1 = 'blah'
and col2 = 'blahblah'
and col3 not in ('blah','blah blah');