Home » Performance » MySQL » should a count with an index take this long?
should a count with an index take this long? [message #1364] Mon, 04 June 2007 23:56 Go to previous message
GeoffreyF67  is currently offline GeoffreyF67
Messages: 21
Registered: May 2007
Junior Member

CREATE TABLE `WikiParagraphs2` (
  `ID` int(9) unsigned NOT NULL auto_increment,
  `Paragraph` text collate utf8_swedish_ci NOT NULL,
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_swedish_ci AUTO_INCREMENT=73035277 ;

mysql> select count(ID) from WikiParagraphs2 where ID < 9999999;
+-----------+
| count(ID) |
+-----------+
|   7375964 | 
+-----------+
1 row in set (44.79 sec)

mysql> explain select count(ID) from WikiParagraphs2 where ID < 9999999;

+----+-------------+-----------------+-------+---------------+---------+---------+------+---------+--------------------------+
| id | select_type | table           | type  | possible_keys | key     | key_len | ref  | rows    | Extra                    |
+----+-------------+-----------------+-------+---------------+---------+---------+------+---------+--------------------------+
|  1 | SIMPLE      | WikiParagraphs2 | range | PRIMARY       | PRIMARY | 4       | NULL | 7997361 | Using where; Using index | 
+----+-------------+-----------------+-------+---------------+---------+---------+------+---------+--------------------------+
1 row in set (0.05 sec)



It says it's using an index so I don't understand why it would take 45 seconds to get the count...any ideas?

Edit: Added table definition.

[Updated on: Tue, 05 June 2007 00:04]


G-Man

Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic:Preventing filesort in a simple (but big) query?
Next Topic:SELECTs to slave, INSERTs to master by application?
Goto Forum:

  


Current Time: Sun Jul 5 22:24:56 EDT 2009

Total time taken to generate the page: 0.00936 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7.
Copyright ©2001-2007 FUD Forum Bulletin Board Software

MySQL is a trademark of Sun Microsystems.
InnoDB is a trademark of Oracle Corp.

Percona Performance Forums are a service of Percona, Inc.
Not affiliated with Sun Microsystems or Oracle Corp.