Hi everyone,
I’m having a predicament in crossing over to Percona. As a new user of Percona we encounter the following problem.
We have an OLD server which is running MySQL 5.0.67-0.dotdeb.1-log.
And we have a NEW server which is running MySQL server 5.5.30-30.1-log Percona Server (GPL), Release 30.1.
We are running the following query on both machines:
SELECT SQL_NO_CACHE ags.status_id FROM ast_stats_agentstatus AS ags force index (status_id) WHERE ags.agent_id = “10963” ORDER BY ags.id DESC LIMIT 1;
Of course, this is a test query, hence the SQL_NO_CACHE.
Performance indicator time that has taken for this query is.
OLD: 0.01 sec
NEW: 0.36 sec
After some more digging with the explain query showed us the following
OLD:
±—±------------±------±-----±--------------±-------- ±--------±------±-----±----------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
±—±------------±------±-----±--------------±-------- ±--------±------±-----±----------------------------+
| 1 | SIMPLE | ags | ref | uniqkey | uniqkey | 4 | const | 1583 | Using where; Using filesort |
±—±------------±------±-----±--------------±-------- ±--------±------±-----±----------------------------+
NEW:
±—±------------±------±------±--------------±------- -±--------±-----±-----±------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
±—±------------±------±------±--------------±------- -±--------±-----±-----±------------+
| 1 | SIMPLE | ags | index | uniqkey | PRIMARY | 4 | NULL | 1408 | Using where |
±—±------------±------±------±--------------±------- -±--------±-----±-----±------------+
This shows us that for the key on OLD the uniqkey is used, and on the NEW setup the PRIMARY key is used.
When forcing the query to use the uniqkey the problem is solved. So using the following query on the new machine results in a query time of 0.01 sec:
SELECT SQL_NO_CACHE ags.status_id FROM ast_stats_agentstatus AS ags force index (uniqkey) WHERE ags.agent_id = “10963” ORDER BY ags.id DESC LIMIT 1;
This leads me to presume that the query optimizer is less effecient that the OLD version.
It is not a option to change all the queries in the application code. Does someone know a different solution for this problem?
I’m also going to investigate what the outcome is going to be when I’m using the latest MySQL Server.