删除操作需要一些时间才能完成
我有一种删除数据库中记录的方法,正确创建查询并删除记录,但在 40 秒到 1 分钟后
如果我在数据库提示中执行查询,记录将立即删除
拥有的代码只是:
- 我 数据库连接
- 准备语句,将 3 个变量传递给“delete from”语句,
- 在语句上调用executeUpdate,
- 在连接上调用 commit,
- 关闭数据库连接,
这可能是什么错误?有什么线索吗?
I have a method to delete records in a DB, the query is created correctly and the records are deleted but after 40 seconds to 1 minute
If i execute the query in the DB prompt the record is deleted immediately
The code i have is only :
- getting the database connection
- preparing the statement passing 3 variables to the "delete from" sentence
- calling executeUpdate on the statement
- calling commit on the connection
- closing the db connection
What could it be wrong? any clue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您隐含地假设 DELETE 语句在所有情况下都非常简单,但这并不总是正确的。至少,它需要在表中找到它想要删除的记录。例如,如果 WHERE 谓词无法利用现有索引,则可能需要进行整个表扫描。
You are implicitly assuming that a DELETE statement is very trivial in all cases, which is not always true. At very least, it needs to find the records it want to remove in the table. This may require an entire table scan if, for example, the WHERE predicate cannot leverage an existing index.