Ok, I got a problem and all of your ideas are real appreciated.
I have a table something like this:
CREATE TABLE `table` (
`table_id` int(11) NOT NULL auto_increment,
`join_id` int(11) NOT NULL default '0',
`data` date NOT NULL default '0000-00-00',
PRIMARY KEY (`table_id`),
KEY `date` (`data`)
) TYPE=MyISAM;
This table got lots of rows, something like 500.000 rows…
Mysql server vers. 4.1.10
When I’m executing this query:
SELECT DISTINCT(UNIX_TIMESTAMP(table.data)) as data, COUNT(table.table_id) as nr, COUNT(DISTINCT(table.join_id)) as nr1 FROM `table` WHERE table.join_id!=0 GROUP BY data ORDER BY data DESC LIMIT 0,10
, its take 9 sec to execute.
Does anyone have some idea of sql optimization?
Thanks for reading this, and any idea is real appreciated.