情景是:需要把學生的錄取志愿資訊更新到資料庫,一共大概7000條記錄,分批次,每次操作200條,因為每個學生錄取的志愿不一定相同,所以我用回圈執行多條sql,但是發現巨慢,druid看了一下,一共花了6分鐘,如果使用MyIsam幾秒鐘就完成了。
mapper 里面是這樣寫的:
<update id="updateAccepted" >
<foreach collection="students" separator=";" item="student">
UPDATE t_student
SET accepted_major_id = #{student.acceptedMajorId}, accepted_type = #{student.acceptedType}
WHERE student_id = #{student.studentId}
</foreach>
</update>
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/189672.html
標籤:MySQL
