2021
08-26
08-26
mysql高效查询left join和group by(加索引)
mysql高效查询mysql牺牲了groupby来增加leftjoin的速度(前提是加了索引)。user表:10万数据实例1:200秒左右SELECTU.id,A.favorite_countFROM(SELECTidfromuser)ULEFTJOIN(--点赞数SELECTfavorite_byASuser_id,SUM(favorite_count)ASfavorite_countFROMfavoriteGROUPBYfavorite_by)AONU.id=A.user_idLEFTJOIN(--评论数量SELECTuser_id,COUNT(*)AScomment_countFROMphoto_comme...
继续阅读 >