【索引】反向索引

简介: 1,Creating dataReversed key indexes use b-tree structures, but preprocess key values before inserting them.
1,Creating data
Reversed key indexes use b-tree structures, but preprocess key values before inserting them. Simplifying, b-trees place similar values on a single index block, e.g., storing 24538 on the same block as 24539. This makes them efficient both for looking up a specific value and for finding values within a range. However if the application inserts values in sequence, each insert must have access to the newest block in the index in order to add the new value. If many users attempt to insert at the same time, they all must write to that block and have to get in line, slowing down the application. This is particularly a problem in clustered databases, which may require the block to be copied from one computer's memory to another's to allow the next user to perform. their insert.

Reversing the key spreads similar new values across the entire index instead of concentrating them in any one leaf block. This means that 24538 appears on the same block as 14538 while 24539 goes to a different block, eliminating this cause of contention. (Since 14538 would have been created long before 24538, their inserts don't interfere with each other.)


2,Querying data
Reverse indexes are just as effective as for finding specific values, although they aren't helpful for range queries, which turn out to be uncommon for artificial values such as sequence numbers. When searching the index, the query processor simply reverses the search target before looking it up.

3,Deleting data
Another benefit impacts applications that delete data. Typically, applications delete data that is older on average (with lower values of the sequence) before deleting newer data. In standard b-trees, many index blocks end up containing few values, with a commensurate increase in unused space, referred to as "rot". Rot not only wastes space, but slows query speeds, because a smaller fraction of a rotten index's blocks fit in memory at any one time. In a b-tree, if 14538 gets deleted, its index space remains empty. In a reverse index, if 14538 goes before 24538 arrives, 24538 can reuse 14538's space.
目录
相关文章
|
索引
索引
索引。
95 0
|
5月前
|
TensorFlow 算法框架/工具 索引
索引
【8月更文挑战第13天】索引。
34 1
|
7月前
|
SQL 关系型数据库 MySQL
MySQL数据库——索引(6)-索引使用(覆盖索引与回表查询,前缀索引,单列索引与联合索引 )、索引设计原则、索引总结
MySQL数据库——索引(6)-索引使用(覆盖索引与回表查询,前缀索引,单列索引与联合索引 )、索引设计原则、索引总结
176 1
|
8月前
|
存储 NoSQL 关系型数据库
索引!索引!!索引!!!到底什么是索引?
**索引是数据库中的数据结构,类似书籍目录,加速数据查找和访问。优点包括提升查询性能、数据检索速度、支持唯一性约束及优化排序和连接操作。缺点在于增加写操作开销、占用存储空间、高维护成本和过多索引可能降低性能。常见的索引类型有单值、复合、唯一、聚集和非聚集索引等,实现方式涉及B树、B+树和哈希表。B树和B+树适合磁盘存储,B+树尤其适用于范围查询,哈希索引则适用于快速等值查询。**
80 0
|
8月前
|
SQL 搜索推荐 关系型数据库
|
8月前
|
存储 算法 关系型数据库
索引总结(2)
索引总结(2)
55 0
|
关系型数据库 MySQL 索引
索引(2)
索引(2)。
48 0
|
存储 SQL 关系型数据库
【名词解释与区分】聚集索引、非聚集索引、主键索引、唯一索引、普通索引、前缀索引、单列索引、组合索引、全文索引、覆盖索引
【名词解释与区分】聚集索引、非聚集索引、主键索引、唯一索引、普通索引、前缀索引、单列索引、组合索引、全文索引、覆盖索引
558 1
【名词解释与区分】聚集索引、非聚集索引、主键索引、唯一索引、普通索引、前缀索引、单列索引、组合索引、全文索引、覆盖索引
|
SQL 关系型数据库 MySQL
表索引——隐藏索引和删除索引
前言 MySQL 8开始支持隐藏索引。隐藏索引提供了更人性化的数据库操作。
|
SQL 数据库 索引
为or、in平反——or、in到底能不能利用索引?
  先说一个笑话,作为开场白。俺也换换风格试一试,呵呵。   在以前,有三个书生赶考,在路上遇到了一个算命先生,于是就问算命先生:我们三个人赶考,结果如何呀?算命先生伸出来了一个手指头(食指)。
1056 0