需求是需要查询用户列表并统计积分,会员表目前有50W,积分表有100W左右的数据,现在这条查询语句需要花十几秒的时间,应该怎么优化?
SELECT
m.username,
m.truename,
m.mobile,
m.company,
m.email,
c.credit
FROM
u_member m
LEFT JOIN (
SELECT
username,
SUM(amount) AS credit
FROM
u_finance_credit
GROUP BY
username
) AS c ON m.username = c.username
ORDER BY
m.userid DESC
LIMIT 0,10;
吃鸡游戏