MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Brian Dunning Date:January 7 2007 6:12pm
Subject:Help optimizing this query?
View as plain text  
This is the query that's killing me in the slow query log, usually  
taking around 20 seconds:

select count(ip) as counted,stamp from ip_addr where stamp>=NOW()- 
interval 14 day and source='sometext' group by stamp order by stamp  

Here is the table:

CREATE TABLE `ip_addr` (
   `ip` int(10) unsigned NOT NULL default '0',
   `stamp` date NOT NULL default '0000-00-00',
   `country` char(2) NOT NULL default '',
   `source` varchar(20) NOT NULL default '',
   PRIMARY KEY  (`ip`),
   KEY `country-source` (`country`,`source`),
   KEY `stamp-source` (`stamp`,`source`)

Any help please?   :)
Help optimizing this query?Brian Dunning7 Jan
  • Re: Help optimizing this query?Daniel Kasak8 Jan
  • RE: Help optimizing this query?Michael Gargiullo8 Jan
    • Re: Help optimizing this query?Dan Buettner8 Jan
      • Re: Help optimizing this query?joce8 Jan