【发布时间】:2025-12-20 17:35:17
【问题描述】:
mysql server config 这里是mysql config,一个很简单的表,innodb,索引不多,但是有时候insert op太慢了,谁能告诉我为什么?
public Long insertCoursewarePage(Env env, Long coursewareId, Integer pageType, String teacherId) throws SQLException {
env.logTiming("beforeGetConnection");
Connection conn = MySql.getInst_education_biz().getConnection();
env.logTiming("afterGetConnection");
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "INSERT INTO `courseware_page`(`courseware_id`, `page_type`, `teacher_id`, `create_time`) VALUES(?,?,?,?)";
try {
pstmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
env.logTiming("afterPrepareStatement");
pstmt.setLong(1, coursewareId);
pstmt.setInt(2, pageType);
pstmt.setString(3, teacherId);
pstmt.setLong(4, System.currentTimeMillis());
pstmt.executeUpdate();
env.logTiming("afterExecuteUpdate");
rs = pstmt.getGeneratedKeys();
env.logTiming("afterGetGeneratedKeys");
if (rs.next()) {
return rs.getLong(1);
}
} finally {
MySql.closeConnection(rs, pstmt, conn);
}
return null;
}
/**
Here is my java code, use jdbc get a connection and I profiled it and the result is below here.
beforeGetConnection=14
afterGetConnection=20
afterPrepareStatement=20
afterExecuteUpdate=5344
afterGetGeneratedKeys=5345
mysql server is on a dell r820, SSD, 64 core cpu, 320G memory, it seems no any problem.so could anybody tell me why
**/
【问题讨论】:
-
请将全部相关代码以文字形式发布。代码编辑器就是为此目的而存在的。
-
对不起,我没有权限回复你,代码img在这里i.stack.imgur.com/vm3GN.png
-
再次,删除图像并将所有相关代码包含为editing the question的文本。
-
@BackSlash 代码在这里