MySQL Query Issue - Count Query Uses lot of CPU -


The table we have mysql to log all visitors to our site structure is shown below

< blockquote>
 CREATE TABLE `tblvisitors` (` visitorURL` LongText, `visitorDatetime` datetime default zero,` visitorIP` varchar (255) default zero, `visitorID` int (10) nOT nULL AUTO_INCREMENT,` visitorUser` varchar (255 ) default zero, `visitorShow` varchar (50) default zero,` visitorIPcaption` varchar (255) default zero, `visitorIPRange` varchar (255) default null, pRIMARY KEY (` visitorID`), KEY `INDEXDT` (` visitor e Ttaim '), key `Indeksip` (` visits Aipi`)) engine = Maisam default charge = latin1; 

The table has recorded more than 5 million now.

We have a combined operation every half second and also select one of the operations every half second which is included on a criteria visitorURL column and select the COUNT field

query.

 select COUNT in (visitorURL) visitorURL Where tblVisitors = 'http: //mihirdarji.com/something' 

With the 8GB RAM CPU usage in the 8 core server shoots up to 90%.

MySQL Administrator shows lots of connection are waiting for the query above.

Any suggestions will be welcomed.

The Explain point plan

 | ID | Select_type | Table | Type | Possible_Keys | Key | Key_len | Referee | Rows | Extra | | 1 | Simple | TblVIsitors | All | Faucet Faucet Faucet Faucet 42 9 3277 | Where to use 

After

  1. first on an index visitorURL
  2. after making the second place Some static COUNT SELECT COUNT (1) tblVisitors WHERE visitorURL = ...

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -