dbTalk Databases Forums  

Table with 400000 rows takes a long time to count

comp.databases.mysql comp.databases.mysql


Discuss Table with 400000 rows takes a long time to count in the comp.databases.mysql forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
InvestorTrade
 
Posts: n/a

Default Table with 400000 rows takes a long time to count - 01-13-2008 , 08:52 AM






I have a table with 400000 rows and when I do a:

SELECT count(*) FROM table1;

it takes over three minutes to come back - the table is already
indexed off the unique primary key id, which is of varchar type.

MySQL is of version 5.0.22 on a CentOS system.

I thought that MySQL, at the least, would do the SELECT count...
without me having to deal with new indexes.

I ran a mysqlcheck --o db1 table1, but that did not seem to do
anything for it.

Any ideas?

Funny when I do an EXPLAIN SELECT COUNT(*) FROM TABLE1; the query
returns immediately, and it shows that it is using the primary index,
and also that there are 4000000 rows from the query.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.