> Hello, > > I have aproximately 1,000,000 rows and I would like to do some query. > The first one is to get the number of row so I do : > > mysql> SELECT COUNT(*) FROM `Log`; > +----------+ > | COUNT(*) | > +----------+ > | 969129 | > +----------+ > 1 row in set (0.00 sec)
MyISAM tables keep a specific count of the number of rows in the table, that is why this query is extremely fast. > mysql> SELECT COUNT(*) AS `Nb` FROM `Log` WHERE `ID` = 49; > +--------+ > | Nb | > +--------+ > | 969129 | > +--------+ > 1 row in set (1 min 20.99 sec) This query is slow, presumably, because MySQL must read all 969129 rows off of the disk and count them, which will take some time depending on the size of the rows and the speed of the system. > But like you can see it, it take a long with the WHERE clause. I use > Pentium III at 650 Mhz with 48 Mb of ram. I think that the probleme > come from the computer but I'm not shure (I need more RAM ?). Yes, your ram will make a difference because the file system will do caching. You may want to read up on Indexes in MySQL and see how they are used to optimize queries and how they can also be cached in the key_buffer. http://www.mysql.com/doc/en/MySQL_indexes.html > Thanks in advance. > > -- > Arno nickg -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]