I am building a simple report for my own company needs which will display data, with inner joining two tables, below the sql query.
SELECT r.user
,CASE
WHEN LENGTH(r.extension) > 6
THEN r.extension
WHEN LENGTH(r.extension) < 6
THEN number_dialed
END AS Telefono
,r.server_ip
,r.start_time
,r.length_in_sec
,c.channel_group
,r.location
FROM recording_log r
INNER JOIN call_log c ON r.vicidial_id = c.uniqueid
WHERE r.extension NOT IN (
'772'
,'55555'
,'5555'
)
AND r.location <> ''
AND c.number_dialed NOT IN (
'8368'
,'8369'
)
AND c.length_in_sec > 10
ORDER BY c.`recording_id`
The two tables needed are recording_log (4,079,371 entries)
and call_log (38,516,966 entries)
.
I have searched and made all the optimizations I could find to the MySql, now the problem stands on the query itself, especially when I try to use a Variable on the WHERE
(ex. WHERE number_dialed like '%334' )