4 messages in com.mysql.lists.clusterRE: ndb unique index performance issues
FromSent OnAttachments
Yong Lee29 Jun 2006 16:01 
Benton, Kevin29 Jun 2006 16:42 
Simon Garner29 Jun 2006 17:40 
Stewart Smith29 Jun 2006 22:29 
Subject:RE: ndb unique index performance issues
From:Benton, Kevin (kevi@amd.com)
Date:06/29/2006 04:42:15 PM
List:com.mysql.lists.cluster

I'm trying to do a query that uses an index along with a unique index and for some reason, the query seems to be doing a table scan. My table has 20 000+ records and my query is taking over 20 seconds to return. Any insight into this problem would be appreciated. Here are the details :

mysql 4.1.12, 2 partitions with 2 servers each hosting a data and sql node:

The explain results tell all...

Do you see in your explain statements, where one says type: range and the other says type: ref? For whatever reason, MySQL chose to use some other way to locate your data. As a result, MySQL created a temporary table to grab what you were asking it for.

You may want to try reversing the order of your comparisons in your select statement.

Since username is a unique key, it seems to me that username is a better primary key to use than id, unless you're using id to save storage space in other tables. Optimization tip - don't use id's for things that are already by themselves, unique and easily indexed.