我正在对具有600万行的表执行以下sql语句:
SELECT
log.all, max(log.created_date) as latest_date, COUNT(all) AS
total_count, type.id as machine_type
FROM sms_log log, machine mac,
machine_type type
WHERE mac.machine_type_id = type.id
AND log.machine_id = mac.id
AND log.from_machine = 1
AND log.phone_number
IN(SELECT data FROM machine_data
WHERE name = 'phonenumber'
AND status = 'active'
AND id
IN(SELECT machine_data_id
FROM machine_connector
WHERE connection_type = 'DATA'
AND status = 'active'
AND machine_id = mac.id))
GROUP BY phone_number
ORDER BY total_count DESC LIMIT 100
我已经索引了几列,但仍然需要很多时间,
帮助我优化sql!