多个相同列索引的 Oracle 性能
我正在使用一个新的 Oracle 数据库,其中一个表具有以下索引:
- 索引 1:ColA、ColB
- 索引 2:ColA
第二个索引是否冗余,这会对性能产生负面影响吗?
I'm Working with a new Oracle DB, with one table having the following indexes:
- Index 1: ColA, ColB
- Index 2: ColA
Is the second index redundant, and Will this have a negative impact on performance?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Google 是我最好的朋友:
http://www.orafaq.com/node/926
主要这篇文章的要点是:
我同意这一点!
事实上,在谷歌中搜索“重复索引”会有不同的答案。
Google is my best friend :
http://www.orafaq.com/node/926
The main point of this article is :
And I'm agree with that !
In fact, search "duplicate indexes" in Google to have different kind of answer.
第二个索引是不同的,并且本身并不冗余。
这个查询怎么样:
Oracle 可以完全从索引 2 回答这个问题。现在,索引 2 预计会比索引 1 小(更少的块)。这意味着,对于上述查询来说,它是一个更好的索引。
如果您的应用程序从未执行过比 Index1 更适合 Index2 的查询,那么它对于您的应用程序来说是多余的。
索引始终是性能权衡。 当执行插入、更新或删除时,需要做额外的工作来维护每个附加索引。
索引提供的性能提高是否足以弥补这一点? 取决于您的应用程序和数据使用情况。
The second index is different and is not redundant per se.
How about this query:
Oracle can answer this question entirely from Index 2. Now, index 2 would be expected to be small (less blocks) than index 1. This means, it is a better index for the above query.
If your application never does a query that suits Index2 better than Index1, then it is redundant for your application.
Indexes are always a performance tradeoff. When an insert, update or delete is performed there is extra work to do in order to maintain each additional index.
Is this more than compensated for by the increased performance provided by the index? Depends on your application and data usage.
第二个索引有点多余 - 任何使用 Index2 的操作都可以使用索引 1。此外,由于还有另一个索引需要更新,写入速度会稍微慢一些。
也就是说,Index2 并不完全多余,因为它可能会更快一点,因为索引本身可能会小得多。
The second index is sort of redundant - any operation that uses Index2 could use Index 1. Also, writes will be slightly slower since there is another index to update.
That said, Index2 is not entirely redundant as it could be a bit faster since the index itself is probably going to be significantly smaller.
如果您的统计信息过时,优化器可能会在需要索引 1 时选择索引 2。 (当然,对优化器的提示可以解决这个问题。)
there is a chance that if your statistics go out of date, the optimizer might choose index 2 when index 1 is needed. (a hint to the optimizer would solve that, of course.)