【发布时间】:2019-07-26 22:12:06
【问题描述】:
我正在为我的应用程序使用 MySql Engine=InnoDB。 有一个表格可以收集来自不同位置的搜索数据并将其保存以供处理。 在特定的时间间隔后,我们使用调度程序删除这些数据。 当我们删除大量行时会出现问题,它不会释放磁盘空间。我们已经将 innodb_file_per_table 设置为 ON。 一种解决方案是运行查询:
Optimize Table <TableName>
但这会导致该特定表上的其他选择操作失败,告诉:
Caused by: java.sql.SQLException: 表定义已更改,请 重试交易 com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:545) 在 com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:513) 在 com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:115) 在 com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1983) 在 com.mysql.cj.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1826) 在 com.mysql.cj.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1923) 在 com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:353) 在 org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:60) ...省略了154个常用帧
我需要一个回收/重用表空间的解决方案。 我正在使用 Spring-boot,所以这个解决方案应该从应用程序中处理。即使需要使用分区,也应该可以从应用程序中配置。
【问题讨论】:
-
有一个主题看起来像这样,但没有令人满意的答案,因为它建议我已经拥有但问题仍然存在的 innodb_file_per_table。
-
Big
DELETEs有问题。以下是几种解决方法:mysql.rjweb.org/doc.php/deletebig
标签: java mysql spring-boot spring-data-jpa innodb