Here is the explain result:
id select_typetable type possible_keys key key_len ref rows Extra
1 PRIMARY cdr ALL NULL NULL NULL NULL 1765 "Using temporary; Using filesort"
3 "DEPENDENT SUBQUERY" cdr ALL dst NULL NULL NULL 1765 "Using where"
2 "DEPENDENT SUBQUERY" cdr ALL NULL NULL NULL NULL 1765 "Using where"
Here is the show create table:
'CREATE TABLE `cdr` (
`calldate` datetime NOT NULL DEFAULT ''0000-00-00 00:00:00'',
`clid` varchar(80) NOT NULL DEFAULT '''',
`src` varchar(80) NOT NULL DEFAULT '''',
`dst` varchar(80) NOT NULL DEFAULT '''',
`dcontext` varchar(80) NOT NULL DEFAULT '''',
`channel` varchar(80) NOT NULL DEFAULT '''',
`dstchannel` varchar(80) NOT NULL DEFAULT '''',
`lastapp` varchar(80) NOT NULL DEFAULT '''',
`lastdata` varchar(80) NOT NULL DEFAULT '''',
`duration` int(11) NOT NULL DEFAULT ''0'',
`billsec` int(11) NOT NULL DEFAULT ''0'',
`disposition` varchar(45) NOT NULL DEFAULT '''',
`amaflags` int(11) NOT NULL DEFAULT ''0'',
`accountcode` varchar(20) NOT NULL DEFAULT '''',
`uniqueid` varchar(32) NOT NULL DEFAULT '''',
`userfield` varchar(255) NOT NULL DEFAULT '''',
`did` varchar(50) NOT NULL DEFAULT '''',
`recordingfile` varchar(255) NOT NULL DEFAULT '''',
`cnum` varchar(40) NOT NULL DEFAULT '''',
`cnam` varchar(40) NOT NULL DEFAULT '''',
`outbound_cnum` varchar(40) NOT NULL DEFAULT '''',
`outbound_cnam` varchar(40) NOT NULL DEFAULT '''',
`dst_cnam` varchar(40) NOT NULL DEFAULT '''',
KEY `calldate` (`calldate`),
KEY `dst` (`dst`),
KEY `accountcode` (`accountcode`),
KEY `ClldateCid` (`calldate`,`clid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1'
Can anybody guide me on how to get this properly done without using sub queries.