`

mybatis使用find_in_set导致cpu占用过高

阅读更多
问题表asks有个字段attids用来保存问题附件的id,多个附件用“,”隔开,比如有两个附件,附件id分别为8和9,则该字段保存内容为“8,9”

问题maper:
<resultMap type="com.ozing.dayi.domains.Ask" id="basicAskRsMapper">
		......省略其他
	<association property="attachList" column="attids" select="com.ozing.dayi.persistence.AttachMapper.findAttachListByIds"/>		
</resultMap>

附件findAttachListByIds的sql如下:
SELECT * FROM attachs WHERE FIND_IN_SET(attaid,#{attids})

用Show Processlist查看,发现经常有上面那句sql,而且mysql经常讲cpu的使用率占到100以上,该加的索引都加了。
因之前遗留问题,无法修改表结构,请问有什么好方法么?
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics