无名指和小指发麻是什么原因| 脸容易红是什么原因| 褥疮用什么药最好| vb610是什么药| 孔子的原名叫什么| 灯五行属什么| 快递已揽件是什么意思| 什么是非甾体抗炎药| 浓绿的什么| 紫苏叶是什么| 无名指戴戒指是什么意思| 梦见谈恋爱很甜蜜是什么意思| 舌苔黄厚吃什么药| 三焦不通吃什么中成药| 神经性皮炎用什么药最好| 号什么意思| 感冒喝什么饮料| 猪肝色是什么颜色| 男人有霉菌是什么症状| 红酒配什么菜| 什么睡姿可以矫正驼背| 什么人容易得妄想症| 多种维生素什么牌子的效果最好| 男人结扎了有什么坏处| 唯我独尊指什么生肖| 睡觉手麻是什么原因引起的女人| 09属什么生肖| 血管瘪是什么原因| 13年属什么生肖| 睡觉后脑勺出汗多是什么原因| 虐狗什么意思| 1935年属什么生肖| 增肌吃什么最好| 狗什么东西不能吃| 妇科炎症吃什么药| 什么是阴虚什么是阳虚| 火车动车高铁有什么区别| 右眼皮跳是什么预兆女| 口腔医学专业学什么| 静脉曲张属于什么科| 慢性咽炎吃什么药| 走麦城是什么意思| 胃为什么会疼| 皮肤发白一块一块的是什么病| 脂肪肝吃什么药最好| 侏儒症是缺乏什么元素| 顶臂长是什么意思| 手抖是什么病的症状| 胃黏膜病变是什么意思| 胃不舒服做什么检查| 汐字五行属什么| 吃什么能阻止性早熟| 白酒兑什么好喝| 你为什么不快乐| 欲望是什么意思| 黑色水笔是什么笔| 兔死狗烹是什么意思| 女人长胡子是什么原因| 神经元是什么| 比是什么| 纳豆是什么东西| 黑眼圈看什么科| 什么东西止血最快| 为什么不建议治疗幽门螺杆菌| 拜谒是什么意思| 星期一右眼皮跳是什么预兆| 头痛吃什么药| 吃什么药减肥效果好| 05属什么生肖| 间接胆红素是什么| 夏天容易出汗是什么原因| 口干舌燥是什么病| 工会主席是什么级别| 爱因斯坦是什么星座| 游龙戏凤是什么意思| 什么药治痒效果最好| 正厅级是什么级别| 八段锦什么时候练最好| 肝肾阴虚吃什么药| 软下疳是什么症状| 日抛什么意思| 星盘是什么| 梦见打蛇是什么预兆| 令加瓦读什么| 怀女儿有什么症状| 甘油三酯高是什么原因| 可什么可什么成语| 不良反应是什么意思| 突然耳朵聋是什么原因| 女性尿路感染是什么原因造成的| 嘴角上扬是什么意思| 山药炖什么好吃| 单反是什么意思| 男戴观音女戴佛有什么讲究| 幽门螺旋杆菌阳性吃什么药| 长期喝什么水可以美白| 宫保鸡丁属于什么菜系| 乳腺增生什么症状| 基础医学是什么| 尿急憋不住尿是什么原因| 灌肠是什么意思| 什么样的阳光填形容词| 农历五月十八是什么日子| pm是什么| 为什么直系亲属不能输血| 腺癌是什么癌| exchange是什么意思| 艾斯挫仑是什么药| 感冒鼻子不通气吃什么药| 早上喝蜂蜜水有什么好处| 载脂蛋白b偏高是什么意思| 什么叫消融术治疗| 怀孕不到一个月有什么症状| 杏林指什么| 痞满是什么意思| 阴阳水是什么水| 梦见被狗追是什么意思| 形单影只什么意思| 蛋白质高是什么原因| 耳道湿疹用什么药| 颈椎骨质增生吃什么药效果好| 痛风用什么药| 腰椎退行性变是什么病| 牙龈为什么会肿| 胃炎吃什么中药效果好| 麦芒是什么意思| 1974属什么| 鞭挞是什么意思| 手术后吃什么伤口愈合快| 海棠果什么时候成熟| 持之以恒的恒是什么意思| 长期吸烟容易引起什么疾病| 脊柱侧弯挂什么科| 六八年属什么生肖| 验孕棒两条杠什么意思| 山竹是什么季节的水果| 诸葛亮号什么| 维生素d有什么作用| b票能开什么车| 爆菊花是什么意思| 插画师是做什么的| 脂蛋白a高是什么原因引起的| 安徽菜属于什么菜系| 喜鹊吃什么食物| 蜈蚣代表什么生肖| 酉鬼念什么| 举措前面搭配什么| 手上长水泡痒用什么药| 夸父是一个什么样的人| 专业服从是什么意思| 菠萝是什么意思| 焦虑症是什么原因引起的| 为什么会有黑眼圈| 吲达帕胺片是什么药| 见多识广是什么生肖| 甲状腺分泌什么激素| 男人肝火旺吃什么药| 什么病会引起恶心| 缺钾有什么症状和危害| 便溏是什么原因引起的| 皮肤容易过敏是什么原因| 嘴巴里起泡是什么原因| 集中的近义词是什么| 物流专员是做什么的| 芦芽是什么| 为什么鱼和熊掌不可兼得| 雯字五行属什么| 痄腮是什么意思| 菱角是什么| 怀孕两天会有什么反应| 基数是什么意思| 辅酶q10有什么作用| 信保是什么| 大兴安岭属于什么市| 脂肪肝应注意什么| 蝙蝠是什么变的| 河东狮吼什么意思| 梦见自己坐火车是什么意思| 教唆什么意思| 梦见捡钱了是什么预兆| 1.5是什么星座| 9.7是什么星座| 眼睛跳是什么原因| 儿童发育迟缓挂什么科| 血管变窄吃什么能改善| 全身痒但是身上什么都没有| 什么降血糖| 里番是什么| 看肝脏挂什么科| 立夏吃什么食物| 九个月的宝宝吃什么辅食食谱| 姻亲是什么意思| 昙花一现是什么生肖| 梦见狗咬别人是什么意思| 梦见男朋友出轨了是什么意思| 硫黄和硫磺有什么区别| 什么的桌椅| 乙肝五项一五阳性什么意思| 什么是胰岛素抵抗| 甲状腺饱满是什么意思| 尿特别黄是什么原因| 衣服最小码是什么字母| 戴玉手镯有什么好处| 女性肛裂要抹什么药好| 脸上出汗多是什么原因| 严肃的什么| 獐子是什么动物| 心梗是什么症状| 谷丙转氨酶偏高吃什么药| 脸部爱出油是什么原因| 八十岁叫什么之年| 腰椎生理曲度变直什么意思| 屁股又叫什么| 老人高烧不退是什么原因| 院士相当于什么级别| 不惑是什么意思| 鱼腥草与什么相克| 什么是有氧运动什么是无氧运动| 心肌炎有什么症状和表现| 追求是什么意思| 2019年什么生肖| 肠道有息肉有什么症状| durex什么意思| 车厘子什么季节成熟| 老鼠最怕什么气味驱赶| 为什么吃芒果会过敏| 煮牛肉放什么调料| 卡其色裙子配什么颜色上衣好看| 1983属什么| 性是什么意思| 为什么不结婚| 发热门诊属于什么科| 避孕药吃多了有什么副作用| 鲁班是干什么的| 舌头中间疼是什么原因| 丙肝是什么| 早上起床头晕是什么原因| 爱情和面包是什么意思| 春天都开什么花| 阴囊湿疹用什么药| 女人右眼跳是什么意思| 牛刀割鸡是什么生肖| 骨质疏松检查什么项目| 白头翁是什么| 柏拉图爱情是什么意思| 倒灌是什么意思| 骨刺挂什么科| 做梦梦见僵尸是什么预兆| 中国梦是什么意思| 猪肝有什么功效| 恋恋不舍的意思是什么| 篮板是什么意思| 什么是矿泉水| 人体最大的细胞是什么| 富甲一方什么意思| 米诺地尔搽剂和米诺地尔酊有什么区别| 腿上有淤青是什么原因| 种草莓是什么意思| 见人说人话见鬼说鬼话是什么意思| 颅脑平扫是检查什么| 西安什么省| 甲状腺什么不能吃| 耳朵上有痣代表什么| 一月四号是什么星座| 百度
百度 外军将帅:俄空军掌门竟是陆军猛将2017年11月,据俄媒报道,51岁的苏洛维金·谢尔盖·弗拉基米洛维奇上将被任命为俄空天军司令员。

A database index is a data structure that improves the speed of data retrieval operations on a database table at the cost of additional writes and storage space to maintain the index data structure. Indexes are used to quickly locate data without having to search every row in a database table every time said table is accessed. Indexes can be created using one or more columns of a database table, providing the basis for both rapid random lookups and efficient access of ordered records.

An index is a copy of selected columns of data, from a table, that is designed to enable very efficient search. An index normally includes a "key" or direct link to the original row of data from which it was copied, to allow the complete row to be retrieved efficiently. Some databases extend the power of indexing by letting developers create indexes on column values that have been transformed by functions or expressions. For example, an index could be created on upper(last_name), which would only store the upper-case versions of the last_name field in the index. Another option sometimes supported is the use of partial index, where index entries are created only for those records that satisfy some conditional expression. A further aspect of flexibility is to permit indexing on user-defined functions, as well as expressions formed from an assortment of built-in functions.

Usage

edit

Support for fast lookup

edit

Most database software includes indexing technology that enables sub-linear time lookup to improve performance, as linear search is inefficient for large databases.

Suppose a database contains N data items and one must be retrieved based on the value of one of the fields. A simple implementation retrieves and examines each item according to the test. If there is only one matching item, this can stop when it finds that single item, but if there are multiple matches, it must test everything. This means that the number of operations in the average case is O(N) or linear time. Since databases may contain many objects, and since lookup is a common operation, it is often desirable to improve performance.

An index is any data structure that improves the performance of lookup. There are many different data structures used for this purpose. There are complex design trade-offs involving lookup performance, index size, and index-update performance. Many index designs exhibit logarithmic (O(log(N))) lookup performance and in some applications it is possible to achieve flat (O(1)) performance.

Policing the database constraints

edit

Indexes are used to police database constraints, such as UNIQUE, EXCLUSION, PRIMARY KEY and FOREIGN KEY. An index may be declared as UNIQUE, which creates an implicit constraint on the underlying table. Database systems usually implicitly create an index on a set of columns declared PRIMARY KEY, and some are capable of using an already-existing index to police this constraint. Many database systems require that both referencing and referenced sets of columns in a FOREIGN KEY constraint are indexed, thus improving performance of inserts, updates and deletes to the tables participating in the constraint.

Some database systems support an EXCLUSION constraint that ensures that, for a newly inserted or updated record, a certain predicate holds for no other record. This can be used to implement a UNIQUE constraint (with equality predicate) or more complex constraints, like ensuring that no overlapping time ranges or no intersecting geometry objects would be stored in the table. An index supporting fast searching for records satisfying the predicate is required to police such a constraint.[1]

Index architecture and indexing methods

edit

Non-clustered

edit

The data is present in arbitrary order, but the logical ordering is specified by the index. The data rows may be spread throughout the table regardless of the value of the indexed column or expression. The non-clustered index tree contains the index keys in sorted order, with the leaf level of the index containing the pointer to the record (page and the row number in the data page in page-organized engines; row offset in file-organized engines).

In a non-clustered index,

  • The physical order of the rows is not the same as the index order.
  • The indexed columns are typically non-primary key columns used in JOIN, WHERE, and ORDER BY clauses.

There can be more than one non-clustered index on a database table.

Clustered

edit

Clustering alters the data block into a certain distinct order to match the index, resulting in the row data being stored in order. Therefore, only one clustered index can be created on a given database table. Clustered indexes can greatly increase overall speed of retrieval, but usually only where the data is accessed sequentially in the same or reverse order of the clustered index, or when a range of items is selected.

Since the physical records are in this sort order on disk, the next row item in the sequence is immediately before or after the last one, and so fewer data block reads are required. The primary feature of a clustered index is therefore the ordering of the physical data rows in accordance with the index blocks that point to them. Some databases separate the data and index blocks into separate files, others put two completely different data blocks within the same physical file(s).

Cluster

edit

When multiple databases and multiple tables are joined, it is called a cluster (not to be confused with clustered index described previously). The records for the tables sharing the value of a cluster key shall be stored together in the same or nearby data blocks. This may improve the joins of these tables on the cluster key, since the matching records are stored together and less I/O is required to locate them.[2] The cluster configuration defines the data layout in the tables that are parts of the cluster. A cluster can be keyed with a B-tree index or a hash table. The data block where the table record is stored is defined by the value of the cluster key.

Column order

edit

The order that the index definition defines the columns in is important. It is possible to retrieve a set of row identifiers using only the first indexed column. However, it is not possible or efficient (on most databases) to retrieve the set of row identifiers using only the second or greater indexed column.

For example, in a phone book organized by city first, then by last name, and then by first name, in a particular city, one can easily extract the list of all phone numbers. However, it would be very tedious to find all the phone numbers for a particular last name. One would have to look within each city's section for the entries with that last name. Some databases can do this, others just won't use the index.

In the phone book example with a composite index created on the columns (city, last_name, first_name), if we search by giving exact values for all the three fields, search time is minimal—but if we provide the values for city and first_name only, the search uses only the city field to retrieve all matched records. Then a sequential lookup checks the matching with first_name. So, to improve the performance, one must ensure that the index is created on the order of search columns.

Applications and limitations

edit

Indexes are useful for many applications but come with some limitations. Consider the following SQL statement: SELECT first_name FROM people WHERE last_name = 'Smith';. To process this statement without an index the database software must look at the last_name column on every row in the table (this is known as a full table scan). With an index the database simply follows the index data structure (typically a B-tree) until the Smith entry has been found; this is much less computationally expensive than a full table scan.

Consider this SQL statement: SELECT email_address FROM customers WHERE email_address LIKE '%@wikipedia.org';. This query would yield an email address for every customer whose email address ends with "@wikipedia.org", but even if the email_address column has been indexed the database must perform a full index scan. This is because the index is built with the assumption that words go from left to right. With a wildcard at the beginning of the search-term, the database software is unable to use the underlying index data structure (in other words, the WHERE-clause is not sargable). This problem can be solved through the addition of another index created on reverse(email_address) and a SQL query like this: SELECT email_address FROM customers WHERE reverse(email_address) LIKE reverse('%@wikipedia.org');. This puts the wild-card at the right-most part of the query (now gro.aidepikiw@%), which the index on reverse(email_address) can satisfy.

When the wildcard characters are used on both sides of the search word as %wikipedia.org%, the index available on this field is not used. Rather only a sequential search is performed, which takes ? ? time.

Types of indexes

edit

Bitmap index

edit

A bitmap index is a special kind of indexing that stores the bulk of its data as bit arrays (bitmaps) and answers most queries by performing bitwise logical operations on these bitmaps. The most commonly used indexes, such as B+ trees, are most efficient if the values they index do not repeat or repeat a small number of times. In contrast, the bitmap index is designed for cases where the values of a variable repeat very frequently. For example, the sex field in a customer database usually contains at most three distinct values: male, female or unknown (not recorded). For such variables, the bitmap index can have a significant performance advantage over the commonly used trees.

Dense index

edit

A dense index in databases is a file with pairs of keys and pointers for every record in the data file. Every key in this file is associated with a particular pointer to a record in the sorted data file. In clustered indices with duplicate keys, the dense index points to the first record with that key.[3]

Sparse index

edit

A sparse index in databases is a file with pairs of keys and pointers for every block in the data file. Every key in this file is associated with a particular pointer to the block in the sorted data file. In clustered indices with duplicate keys, the sparse index points to the lowest search key in each block.

Reverse index

edit

A reverse-key index reverses the key value before entering it in the index. E.g., the value 24538 becomes 83542 in the index. Reversing the key value is particularly useful for indexing data such as sequence numbers, where new key values monotonically increase.

Inverted index

edit

An inverted index maps a content word to the document containing it, thereby allowing full-text searches.

Primary index

edit

The primary index contains the key fields of the table and a pointer to the non-key fields of the table. The primary index is created automatically when the table is created in the database.

Secondary index

edit

It is used to index fields that are neither ordering fields nor key fields (there is no assurance that the file is organized on key field or primary key field). One index entry for every tuple in the data file (dense index) contains the value of the indexed attribute and pointer to the block or record.

Hash index

edit

A hash index in database is most commonly used index in data management. It is created on a column that contains unique values, such as a primary key or email address.

Linear hashing

edit

Another type of index used in database systems is linear hashing.

Index implementations

edit

Indices can be implemented using a variety of data structures. Popular indices include balanced trees, B+ trees and hashes.[4]

In Microsoft SQL Server, the leaf node of the clustered index corresponds to the actual data, not simply a pointer to data that resides elsewhere, as is the case with a non-clustered index.[5] Each relation can have a single clustered index and many unclustered indices.[6]

Index concurrency control

edit

An index is typically being accessed concurrently by several transactions and processes, and thus needs concurrency control. While in principle indexes can utilize the common database concurrency control methods, specialized concurrency control methods for indexes exist, which are applied in conjunction with the common methods for a substantial performance gain.

Covering index

edit

In most cases, an index is used to quickly locate the data records from which the required data is read. In other words, the index is only used to locate data records in the table and not to return data.

A covering index is a special case where the index itself contains the required data fields and can answer the required data.

Consider the following table (other fields omitted):

ID Name Other Fields
12 Plug ...
13 Lamp ...
14 Fuse ...

To find the Name for ID 13, an index on (ID) is useful, but the record must still be read to get the Name. However, an index on (ID, Name) contains the required data field and eliminates the need to look up the record.

Covering indexes are each for a specific table. Queries which JOIN/ access across multiple tables, may potentially consider covering indexes on more than one of these tables.[7]

A covering index can dramatically speed up data retrieval but may itself be large due to the additional keys, which slow down data insertion and update. To reduce such index size, some systems allow including non-key fields in the index. Non-key fields are not themselves part of the index ordering but only included at the leaf level, allowing for a covering index with less overall index size.

This can be done in SQL with CREATE INDEX my_index ON my_table (id) INCLUDE (name);.[8][9]

Standardization

edit

No standard defines how to create indexes, because the ISO SQL Standard does not cover physical aspects. Indexes are one of the physical parts of database conception among others like storage (tablespace or filegroups).[clarify] RDBMS vendors all give a CREATE INDEX syntax with some specific options that depend on their software's capabilities.

See also

edit

References

edit
  1. ^ "CREATE TABLE". PostgreSQL Documentation. October 27, 2016.
  2. ^ Overview of Clusters Oracle? Database Concepts 10g Release 1 (10.1)
  3. ^ Database Systems: The Complete Book. Hector Garcia-Molina, Jeffrey D. Ullman, Jennifer D. Widom
  4. ^ Gavin Powell (2006). Chapter 8: Building Fast-Performing Database Models. Wrox Publishing. ISBN 978-0-7645-7490-0. {{cite book}}: |work= ignored (help)
  5. ^ "Clustered Index Structures". SQL Server 2005 Books Online (September 2007). 4 October 2012.
  6. ^ Daren Bieniek; Randy Dess; Mike Hotek; Javier Loria; Adam Machanic; Antonio Soto; Adolfo Wiernik (January 2006). "Chapter 4: Creating Indices". SQL Server 2005 Implementation and Management. Microsoft Press.
  7. ^ "Covering Indexes for Query Optimization | Literate Java". June 13, 2016.
  8. ^ "11.9. Index-Only Scans and Covering Indexes". PostgreSQL Documentation. 2025-08-05. Retrieved 2025-08-05.
  9. ^ MikeRayMSFT. "Create indexes with included columns - SQL Server". learn.microsoft.com. Retrieved 2025-08-05.
ppi下降意味着什么 腿水肿是什么原因 长期喝咖啡有什么好处和坏处 什么是压缩性骨折 工事是什么意思
雌激素低吃什么药 通马桶的工具叫什么 喉结下面是什么部位 十一月一号是什么星座 东方蝾螈吃什么
女生两个月没来月经是什么原因 生活的意义是什么 膝盖积液挂什么科 阴虚火旺吃什么食物好 荨麻疹去药店买什么药
准奏是什么意思 迎合是什么意思 小米是什么 痛风脚痛吃什么药 什么叫原研药
被动什么意思hcv9jop4ns9r.cn 绝经后吃什么能来月经hcv8jop5ns2r.cn 强颜欢笑是什么意思hcv8jop9ns6r.cn 什么是狐臭hcv7jop6ns6r.cn 打招呼是什么意思hcv9jop3ns9r.cn
hpv低危型是什么意思hcv7jop5ns6r.cn 肚子胀不消化吃什么药hcv9jop6ns4r.cn 聿五行属什么beikeqingting.com 东北人喜欢吃什么菜bjhyzcsm.com 扁桃体发炎引起的发烧吃什么药hcv9jop1ns5r.cn
红红火火是什么生肖hcv8jop3ns3r.cn 滑丝是什么意思hcv9jop3ns4r.cn 兰桂齐芳是什么意思onlinewuye.com 1955年出生属什么hcv8jop7ns3r.cn 姓傅的男孩取什么名字hcv9jop2ns1r.cn
心脏造影是什么检查hcv8jop7ns2r.cn md是什么职位hcv9jop2ns0r.cn 交感神经型颈椎病吃什么药hcv9jop3ns0r.cn 骨质疏松是什么症状hcv9jop0ns9r.cn 吃什么食物增加黑色素hcv9jop8ns2r.cn
百度