-----Original Message-----
From: Brian Dunning [mailto:[EMAIL PROTECTED] 
Sent: Sunday, January 07, 2007 1:12 PM
To: mysql
Subject: Help optimizing this query?

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  
desc;

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`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Any help please?   :)

---

Just a thought? Put a normal index on source and another on stamp (not
combined).




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to