我从mysql中查询数据,然后将查询到的数据插入到另一个数据库中,目前速度查询5000个并插入的速度大概在45秒到200秒之间。怎样可以提升它的速度。这条sql本身的执行时间在numiid很多的时候或者表中数据较多的时候就较慢,有时在1.6秒以上sql:select ir.id,iss.numIid,iss.bid,b.bname as bT,iss.cid,c.name as cT,iss.userId ,ss.shopTitle,iss.title as itemTitle,ir.type,ir.page,if(count(keyword) is null,0,count(keyword)) keywordCount1,IF(k.ssrq is null, 0,sum(k.ssrq )) ssrqCount1,if(iss.sales!=-1,iss.sales,IF(iss.trades!=-1,iss.trades,iss.receivers)) salesCount1 from table iss inner join table0 ir on iss.numIid=ir.numIid <if test="type != null"> and ir.type =#{type}</if> <if test="type == null"> and ir.type in (1,2,3,4,11,12,13,21,22,31,32)</if> <if test="page != null"> and ir.page =#{page}</if> <if test="page == null"> and ir.page in(1,2,3,4,5,6,7,8,9,10) </if> left join table1_${batchId} k on ir.keyword =k.id left join table2_${batchId} ss on ss.userId =iss.userId left join table3 b on iss.bid=b.bid left join table4 c on iss.cid=c.id where iss.numIid in ( <foreach collection="numIids" item="numIid" separator=","> #{numIid} </foreach> ) group by iss.numIid,ir.page,ir.type
添加回答
举报
0/150
提交
取消