硒是什么东西| 骨盐量偏低代表什么| 啫啫煲为什么念jue| 什么啊| 各自安好什么意思| 遇人不淑什么意思| 蛤蟆吃什么| winner什么意思| 艾是什么意思| 圣字五行属什么| 小孩便秘吃什么通便快| 咖啡对身体有什么危害| 12388是什么电话| 经常出鼻血是什么原因| 胸部里面有个圆圆的硬东西是什么| 针眼是什么| 玉米不能和什么食物一起吃| 黄金属于五行属什么| 女性下面流水什么原因| fw什么意思| 虾和什么食物相克| 有小肚子是什么原因| 清华大学校长是什么级别| 肉偿是什么意思| 不管事是什么意思| 小路像什么| 芋圆是什么做的| 日落胭脂红的下一句是什么| 黄瓜敷脸有什么效果| 下焦湿热吃什么中成药| 子宫内膜14mm说明什么| 什么东西补铁效果好而且最快| 白发用什么染发最安全| 指甲变黄是什么原因| 乳岩是什么病| 女生问你喜欢她什么怎么回答| 英语6级是什么水平| 睾丸变小了是什么原因| 月和什么有关| 眷属是什么意思| 女人左眼跳是什么意思| 心存善念是什么意思| 中元节是什么节日| 容祖儿老公叫什么名字| 脸为什么容易红| 特别想睡觉是什么原因| 乐色是什么意思| 口腔异味是什么原因引起的| 开导是什么意思| 万马奔腾是什么生肖| 二型血糖高吃什么药好| 什么是次数| 体脂是什么| 喝酒有什么好处| 学业是什么意思| 表现优异是什么意思| 主动脉夹层是什么原因引起的| 肺纹理增粗是什么意思| 下限是什么意思| 什么如什么| 一孕傻三年是什么意思| 怀孕后乳房有什么变化| 叶公好龙的好是什么意思| 狼藉是什么意思| 臻字五行属什么| 异的偏旁是什么| 吃什么排肝毒最快| 梦见吃豆腐是什么意思| 桐五行属什么| 胃复安是什么药| 八股文是什么| a4腰什么意思| 血脂高吃什么中药| 毛囊炎是什么| 轻度高血压吃什么食物可以降压| 什么叫智齿| 打九价是什么意思| 体现是什么意思| 报应不爽什么意思| 什么东西有助于睡眠| 什么是潜规则| 孕妇吃西红柿对胎儿有什么好处| 京五行属什么| 老鼠长什么样子图片| 发烧不退烧是什么原因| 荷花的别称是什么| 朱元璋长什么样| 胰腺炎不能吃什么| 为什么养鱼双数是大忌| 胃酸是什么症状| 月经过后腰酸疼是什么原因| 午时是什么时间| 权倾朝野是什么意思| 一指什么生肖| 91是什么意思| diff什么意思| 嘴唇干是什么原因引起的| 穿拖鞋脚臭是什么原因| jerry英文名什么意思| wendy什么意思| 马瘦毛长是什么意思| 子衿什么意思| 梦见车掉水里了什么征兆| 大腿肌肉疼是什么原因| 莲蓬吃了有什么好处| 洗耳恭听什么意思| joeone是什么牌子| 河里的贝壳叫什么| 龙代表什么象征意义| 手指甲空了是什么原因| 13层楼房有什么说法吗| 儿童感冒咳嗽吃什么药| 七星瓢虫吃什么| 自相矛盾是什么意思| 金桔什么时候开花结果| 手指关节肿痛用什么药| 什么的小草| 膝盖不舒服挂什么科| 厨房墙砖什么颜色好看| 因子是什么| 肺ca是什么病| 感觉有痰咳不出来是什么原因| 腿痒是什么原因| 88年属什么的| 鲩鱼是什么鱼| 7月24日是什么日子| 不成敬意什么意思| 脸肿是什么原因引起的| 绿色和红色混合是什么颜色| 肠息肉是什么原因引起的| 肚脐下四指是什么位置| 安乃近是什么药| 士多店是什么意思| 微信什么时候推出的| 1996年属什么生肖| 吃什么降血脂最快最好| 头发没有光泽是什么原因| 腱鞘囊肿看什么科| 偏头痛是什么原因| 妇科tct检查什么| 梦见死了人是什么意思| 小儿急性喉炎吃什么药| 体液是指什么| 弧度是什么意思| 参事是什么级别| 不能生育的女人有什么特征| 烟火气是什么意思| 缓释是什么意思| 星期三打喷嚏代表什么| 糖尿病人能吃什么水果| abi医学上是什么意思| swisse是什么意思| 腺癌是什么癌| 癫痫病是什么原因引起的| 右半边头痛是什么原因| 老年人流鼻血是什么原因| 富三代是什么意思| 双肺间质性改变是什么意思| 中暑什么感觉| 天蝎座什么星象| 食物中毒拉肚子吃什么药| 9月14日是什么星座| 一般什么人戴江诗丹顿| 晚上胃疼是什么原因| 鬼是什么意思| 宋江的绰号是什么| 忆苦思甜下一句是什么| 抄经书有什么好处| 下巴肿大是什么原因| 黄色加蓝色等于什么颜色| t1w1高信号代表什么| 奥氮平片是什么药| 查肝功能能查出什么病| 心眼是什么意思| 财多身弱什么意思| 支原体培养阳性是什么意思| 男人洁身自好什么意思| 吸入甲醛会有什么症状| 全身发烫但不发烧是什么原因| 梦见大火烧房子是什么意思| 阴茎是什么| 弱视和近视有什么区别| 什么叫周围神经病| 过敏性鼻炎喝什么茶好| 减脂吃什么蔬菜| 舌苔腻是什么意思| 腰间盘突出压迫神经什么症状| 女生的胸部长什么样| ooc是什么意思| 胆固醇高不可以吃什么食物| 体内湿气太重吃什么药能快速除湿| 非浅表性胃炎是什么意思| prc是什么意思| 肌肤甲错是什么意思| 南京鸡鸣寺求什么灵| 农历七月份是什么星座| 什么入胜| 潼字五行属什么| 甲状腺是由什么引起的| 吃什么帮助消化通便| 五月十三日是什么星座| 中医心脉受损什么意思| 照身份证穿什么衣服| 尿味重是什么原因| 怕空调冷风什么原因| 瑕疵是什么意思| 什么人不能摆放大象| 赢弱什么意思| 柠檬水喝了有什么好处| 送男生什么礼物| 停经吃什么能来月经| 膝盖凉是什么原因| 嗓子疼咳嗽挂什么科| 天经地义是什么意思| 挂科有什么影响| 药店属于什么单位性质| 维生素c什么牌子好| 心肌酶谱是查什么的| 存在感是什么意思| 晚上吃黄瓜有什么好处| 又热又冷是什么原因| 为什么插几下就射了| 血栓吃什么药可以疏通血管| 傲慢表情是什么意思| 令妹是什么意思| 冠状动脉粥样硬化性心脏病吃什么药| 甲状腺病变是什么意思| 什么是优质碳水| 花甲是什么意思| 做肝功能检查挂什么科| 什么食物防辐射| 禳是什么意思| 守旧是什么意思| 小孩肠胃炎吃什么药| thc是什么费用| 意中人是什么意思| 蜂王浆有什么功效| 牛牛是什么| 怼怼是什么意思| 至加秦是什么字| 生小孩有什么补贴政策| 什么是射精| 五指毛桃什么人不能吃| 什么牌子的冰箱最好| 羊水指数是什么意思| 胆红素三个指标都高是什么原因| 滑胎是什么意思| 坐飞机需要什么证件| 少字五行属什么| 老放屁吃什么药好| ts什么意思网络上| 家里有壁虎是什么原因| omega什么意思| 妊娠高血压对胎儿有什么影响| 女人吃什么能活血化瘀| 钟爱一生是什么意思| 小巫见大巫是什么意思| 德艺双馨是什么意思| 孕妇喝什么牛奶对胎儿好| 声音沙哑是什么原因| 举案齐眉是什么意思| 今年农历是什么年| 什么是玫瑰痤疮| 丽江机场叫什么名字| 百度

共享单车围城公共自行车如何突围 专家:加大郊区投放

百度 中共中央政治局常委、全国政协十三届一次会议主席团会议主持人汪洋参加看望和讨论。

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-06. Retrieved 2025-08-06.
  9. ^ MikeRayMSFT. "Create indexes with included columns - SQL Server". learn.microsoft.com. Retrieved 2025-08-06.
珍珠婚是什么意思 甲醛会导致什么病 樱花的花语是什么 尿液中有白色沉淀物是什么原因 赵匡胤为什么不传位给儿子
血压低压高吃什么药 舍我其谁是什么意思 忌出行是什么意思 阴性阳性什么意思 淋巴结稍大是什么意思
威士忌什么味道 长期戴耳机有什么危害 肚子胀气用什么药 线下培训是什么意思 衄血是什么意思
忏悔是什么意思 右手小指戴戒指什么意思 为什么会血热 硫酸亚铁适合浇什么花 b型血rh阳性是什么意思
知了猴是什么东西hcv8jop4ns4r.cn 女性潮热是什么症状hcv9jop0ns6r.cn 手心发热吃什么药hcv9jop4ns3r.cn 甘油三酯高有什么症状hcv8jop6ns7r.cn 父亲ab型母亲o型孩子什么血型hcv8jop2ns8r.cn
荤菜是什么意思hcv9jop3ns6r.cn 什么药补气血效果最好hcv8jop5ns9r.cn ccd是什么意思yanzhenzixun.com 湿疹是什么症状及图片hcv9jop2ns9r.cn 高锰酸钾有什么作用cj623037.com
乙肝二四五阳性什么意思hcv8jop7ns8r.cn 八字桃花是什么意思hcv7jop6ns5r.cn 为什么拔罐肩膀最黑hcv8jop4ns8r.cn 眼睛经常充血是什么原因引起的hcv8jop0ns0r.cn 面瘫是什么mmeoe.com
1月21号是什么星座hcv8jop0ns5r.cn 什么是凶宅0297y7.com 5是什么生肖hcv8jop5ns8r.cn 用什么泡脚去湿气寒气hcv8jop3ns2r.cn 田螺小子是什么意思hcv7jop5ns4r.cn
百度