在空表中查询执行速度缓慢。 (删除大量插入后)

发布于 2024-10-07 10:33:34 字数 194 浏览 1 评论 0原文

我在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

女皇必胜 2024-10-14 10:33:34

正如 Gritem 所说,您需要了解高水位线等

如果您现在不想截断表(因为已插入新数据),请使用alter table xyz收缩空间 > 此处记录了 10g

As 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), use alter table xyz shrink space documented here for 10g

一片旧的回忆 2024-10-14 10:33:34

Tom 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.

不如归去 2024-10-14 10:33:34

在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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文