I am using 1 million record to run this query, but never give me result even after 200 seconds, thus I kill the query. Below is the query
SELECT truncate((SELECT coalesce(sum(credit-debit),0) FROM trans_laga where uid = a.uid
AND wallet_type = a.wallet_type AND status = 1 and freeze=0 and id<=a.id), 4)
FROM `trans_laga` AS `a`
WHERE a.status =1 AND a.wallet_type != 4 ORDER BY `a`.`id` desc
LIMIT 0, 50000;
Below is the explain output
Why this query running too slow, not even give me the result?
