以下是我的查询,我在包含超过 91000 条记录的表上执行我的 sql。
select l.*
from localcdrsmem l
LEFT JOIN (
SELECT LocalCDRID, ForeignCDRsID
from localcdrsmem l
INNER JOIN foreigncdrsmem f
ON l.CalledNumber=f.CalledNumber and
ABS(l.Duration-f.Duration)<= 2 and
ABS(TIMESTAMPDIFF(SECOND,f.StartTime,l.StartTime))<=100
group by l.CalledNumber)
as temp ON l.LocalCDRID = temp.LocalCDRID
where temp.LocalCDRID IS NULL;
表是:
localcdrsmem - >
+---------+------------+--------+----------
localcdrid | callednumber | duration | starttime
+---------+------------+--------+----------+
foreigncdrsmem- >
+------------+------------+--------+----------
foreigncdrid | callednumber | duration | starttime
+---------+------------+--------+----------+
优化此查询的任何想法?