在空表中查询执行速度缓慢。 (删除大量插入后)
我在oracle数据库中有一个表,有15个字段。 该表有 3500000 个插入。我把它们全部删除了。
delete
from table
之后,每当我执行 select 语句时
即使桌子是空的,我的响应也非常慢(7秒)。 仅在我搜索的情况下才得到正常响应 根据索引字段。
为什么?
I have a table in an oracle database with 15 fields.
This table had 3500000 inserts. I deleted them all.
delete
from table
After that, whenever I execute a select statement
I get a very slow response (7 sec) even though the table is empty.
I get a normal response only in the case that I search
according to an indexed field.
Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如 Gritem 所说,您需要了解高水位线等
如果您现在不想
截断
表(因为已插入新数据),请使用alter table xyz收缩空间
> 此处记录了 10gAs Gritem says, you need to understand high water marks etc
If you do not want to
truncate
the table now (because fresh data has been inserted), usealter table xyz shrink space
documented here for 10gTom Kyte 对这个问题有一个很好的解释:
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:492636200346818072
它应该可以帮助您了解删除、截断和高水位线等。
Tom Kyte has a good explanation of this issue:
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:492636200346818072
It should help you understand deletes, truncates, and high watermarks etc.
在sql中,当你想完全清除一个表时,你应该使用truncate而不是delete。假设您的表中有 350 万行,并且 bigint 列上有一个索引(唯一标识符),该索引随着每行递增。截断表将完全清除表并将索引重置为 0。删除不会清除索引,并且在插入下一条记录时将继续到 3,500,001。截断也比删除快得多。阅读下面的文章以了解其中的差异。
阅读这篇文章阅读这篇文章,其中解释了截断和删除之间的区别。每一种都有使用的时候。 这里是从 Oracle 角度来看的另一篇文章。
In sql when you want to completely clear out a table, you should use truncate instead of delete. Let's say you have your table with 3.5 million rows in it and there is an index (unique identifier) on a column of bigint that increments for each row. Truncating the table will completely clear out the table and reset the index to 0. Delete will not clear the index and will continue at 3,500,001 when the next record is inserted. Truncate is also much faster than delete. Read the articles below to understand the differences.
Read this article Read this article that explains the difference between truncate and delete. There are times to use each one. Here is another article from an Oracle point of view.