位图索引如何工作?
有谁可以帮助我获得位图索引和反向键索引的逻辑表示吗?
Is there anyone who can help me get the logical representation of a bitmap index and reverse key index?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
反向键索引(在 Oracle 中)只是键相反的常规(B 树)索引(1234 变为 4321)。如果您添加递增键,这可能会防止索引不平衡。它还使得范围扫描变得不可能,所以在使用它时你应该知道你在做什么。
位图索引与 B 树索引完全不同。您可以将其视为每个键值的长位数组,每行一个条目,如果该行具有该值则设置为 true,如果没有则设置为 false。对于只有几个不同值(例如,MALE、FEMALE)的列,这效果更好(比 B 树索引)。您可以压缩这些位数组,然后它们变得非常紧凑并且可以快速扫描。
位图索引的主要问题是更新它们需要大量工作,因此它们更适合仓储场景,其中数据在夜间批量加载,然后仅在白天查询(而不更改)。
维基百科也有一个很好的关于位图索引的页面。
A reverse key index (in Oracle) is just a regular (B-tree) index with the keys reversed (1234 becomes 4321). This may prevent unbalanced indexes if you add incrementing keys. It also makes range scans impossible, so you should know what you are doing when using this.
A bitmap index is completely different from a B-tree index. You can think of it as a long bit array for every key value, with one entry for every row, set to true if the row has this value, false if not. This works better (than B-tree indexes) for columns with only a few distinct values (just MALE, FEMALE for example). You can compress these bit arrays, and then they become very compact and fast to scan.
The main problem with bitmap indexes is that it is a lot of work to update them, so that they are more suited for warehousing scenarios, where the data gets loaded in a nightly batch and then only queried (and not changed) during the day.
Wikipedia has a good page about bitmap indexes, too.