2 messages in com.mysql.lists.mysql[7241] Indexes on columns that are de...
FromSent OnAttachments
Stephen Brownlow19 May 2002 22:12 
Dan Nelson19 May 2002 22:20 
Subject:[7241] Indexes on columns that are declared differently?
From:Stephen Brownlow (ste@cfs.com.au)
Date:05/19/2002 10:12:06 PM
List:com.mysql.lists.mysql

The MySQL online manual says that MySQL cannot use indexes efficiently unless the columns have the same type and the same length.

I can see no release notes that this problem has been fixed.

My question: Is this still a problem?

Here is the extract from the latest manual: 7.29 EXPLAIN Syntax (Get Information About a SELECT)

------------------------------ One problem here is that MySQL can't (yet) use indexes on columns efficiently if they are declared differently. In this context, VARCHAR and CHAR are the same unless they are declared as different lengths. Because tt.ActualPC is declared as CHAR(10) and et.EMPLOYID is declared as CHAR(15), there is a length mismatch.

To fix this disparity between column lengths, use ALTER TABLE to lengthen ActualPC from 10 characters to 15 characters:

mysql> ALTER TABLE tt MODIFY ActualPC VARCHAR(15);

---------------------------------

Thanks, Stephen