求大神指点,sql大数据量处理
服务器端以http格式发送数据过来,我这边做快速入库不过目前为止,40毫秒能处理一条,再多就会出现问题
代码如下
ResultSet rs2 = null;
String mosql="select phone,linkid,momsg,port,stat,receiveMode from WebDL..mosync where mopage ='"+pathInfo+"' and onoff=1 ;";
PreparedStatement ps2 = conn.prepareStatement(mosql);
rs2 = ps2.executeQuery();
if(rs2.next()){
momsg = req.getParameter(rs2.getString("momsg"))==null ? "" : req.getParameter(rs2.getString("momsg"));
port = req.getParameter(rs2.getString("port"))==null ? "" : req.getParameter(rs2.getString("port"));
Phone_Num = req.getParameter(rs2.getString("phone"))==null ? "" : req.getParameter(rs2.getString("phone"));
linkid = req.getParameter(rs2.getString("linkid"))==null ? "" : req.getParameter(rs2.getString("linkid"));
stat = req.getParameter(rs2.getString("stat"))==null ? "DELIVRD" : req.getParameter(rs2.getString("stat"));
receiveMode=rs2.getString("receiveMode");
String insertSql="insert into WebDL..moinfor(phone,port,momsg,linkid,onoff,stat,receiveMode) "+
"values('"+Phone_Num+"','"+port+"','"+momsg+"','"+linkid+"',1,'"+stat+"','"+receiveMode+"');";
ps2=conn.prepareStatement(insertSql);
ps2.executeUpdate();
//String insertSql="insert into WebDL..moinfor(linkid,onoff,stat,receiveMode) "+
//"values('"+linkid+"',1,'"+stat+"','mr');";
} sql insert --------------------编程问答-------------------- 用executeBatch()试试呢。。。 --------------------编程问答-------------------- 数据大的时候,循环遍历操作单条数据性能是最差的。如上,批量Insert或者封装成一个事务。会让效率成倍的增长。
补充:Java , Web 开发