MySQL Forums
Forum List  »  Performance

Slow query performance
Posted by: Matt Tessar
Date: October 13, 2004 05:23PM

Hello,

I have reproduced a SQL Server database on MySQL version 4.1.4 gamma max. The table has approximately 200K rows and 30 small fields. The table's primary key is a 12 digit string. Performance is very slow on counts and queries that use only the primary key. The following query takes about 3 seconds on Mysql, and is almost instantaneous on SQL Server.

SELECT COUNT(BLOCKGROUP_ID) FROM BLOCKGROUP_DEMOGRAPHIC;

The output of explain for this command is:

mysql> explain select count(*) from blockgroup_demographic;
+----+-------------+------------------------+-------+---------------+---------+---------+------+--------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+------------------------+-------+---------------+---------+---------+------+--------+-------------+
| 1 | SIMPLE | blockgroup_demographic | index | NULL | PRIMARY | 12 | NULL | 208685 | Using index |
+----+-------------+------------------------+-------+---------------+---------+---------+------+--------+-------------+
1 row in set (0.01 sec)

It seems like it is using the index, but performance suggests otherwise. When I perform a select count on any other field performance is similar at 3 seconds.

Does anyone have any idea why this query is running so slow?

Thanks
Matt


see

Options: ReplyQuote


Subject
Views
Written By
Posted
Slow query performance
5093
October 13, 2004 05:23PM
2688
October 13, 2004 10:01PM
2772
October 13, 2004 10:48PM
2580
October 14, 2004 08:50AM
2753
October 14, 2004 07:08PM
2524
October 14, 2004 11:33PM
2533
October 15, 2004 12:30AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.