1000/nMesgPerSecond
上面我有一个WHERE'查询',它确保一个数字不在一个不调用列表中,一个包含20,000,000行的表,一天没有被响过3次而且没有被调用x次总共。我怎么能加快速度,因为我需要它几乎是即时的。
目前需要一段时间才能在1.5米的列表中找到该号码。
答案 0 :(得分:0)
最好使用NOT EXISTS
代替NOT IN
语句。
'not exists' and 'not in', which one has better performance?
我建议您使用他们的铃声计数来获取所有不在呼叫列表中的号码,并删除之后不需要的号码。
select l.*, (SELECT COUNT(1)
FROM dialler_history
WHERE telephone_number = l.telephone_number
AND (last_called >= ' . $start . '
AND last_called <= ' . $end . ')) d2_count,
(SELECT COUNT(1) FROM dialler_history
WHERE telephone_number = l.telephone_number) d14_count
from phone_number_table l
not exists
(SELECT 1
FROM tps_database WHERE telephone_number = l.telephone_number)
AND not exists
(SELECT 1
FROM dialler_dnc
WHERE telephone_number = l.telephone_number)
and not exists (SELECT 1
FROM dialler_callback
WHERE number_id = l.id)