mysql - query taking long to execute -
i using sql, want delete repeating rows table emaillikebusiness_2 compares data table called per2 query using is
delete emaillikebusiness_2 emaillikebusiness_2.email_id in ( select per2.businessemail2 per2 );
the explain statement gives output
'1', 'primary', 'emaillikebusiness_2', 'all', null, null, null, null, '30670', 'using where' '2', 'dependent subquery', 'per2', 'all', 'idx_email2person2', null, null, null, '24710', 'range checked each record (index map: 0x1)'
i have created index on both table , tried creating index on individual table still query taking long time execute. there anyway can reduce query execution time
mysql tends optimize where ... in (select ...)
poorly. use join instead:
delete e.* emaillikebusiness_2 e join per2 p on e.email_id = p.businessemail2
i've found in
, full scan of first table, searching email_id
in index of second table, if first table larger second one. join, more efficient match between indexes of 2 tables.
Comments
Post a Comment