Index

Why Trust Techopedia

What Does Index Mean?

In database systems, an index (IDX) is a data structure defined on columns in a database table to significantly speed up data retrieval operations. An index is a small copy of a database table sorted by key values. Without an index, query languages like SQL may have to scan the entire table from top to bottom to choose relevant rows.

Advertisements

Techopedia Explains Index

An index on a database table must be created with care, as indexes consume space and are stored in the database. An index can also cause write operations to take more time, as the index must be updated when the underlying table is updated.

The different data structures used to create indexes are B+ trees, balanced trees and hashes. Using these data structures, a scan on the entire database table is relatively easy.

Indexes can also be created on functions or expressions. A unique index prevents duplicate entries in the index and the related table, thus acting as a constraint. Column order is also an important aspect of indexing. The first indexed column always has a priority; row identifiers are retrieved based on the first indexed columns. In a normal scenario, indexes do not return a value but only locate records.

There are generally two types of index architecture:

  • Clustered Indexes: Clustered indexes store row data in order. Only a single clustered index can be created on a database table. This works efficiently only if data is sorted in increasing and decreasing order or a limit is specified on the columns involved in the table. Such a sequential arrangement of data on disks reduces block reads.
  • Non-Clustered Indexes: In non-clustered indexes, data is arranged in a random way, but a logical ordering is internally specified by the index. Thus, the index order is not the same as the physical ordering of data. A “create index” statement creates a non-clustered index by default, which also creates a clustered index on the primary key. The index keys are sorted here with the leaf containing a pointer to the page. Non-clustered indexes work well with tables where data is modified frequently and the index is created on columns used in order by WHERE and JOIN statements.
Advertisements

Related Terms

Margaret Rouse
Technology Expert
Margaret Rouse
Technology Expert

Margaret é uma premiada redatora e professora conhecida por sua habilidade de explicar assuntos técnicos complexos para um público empresarial não técnico. Nos últimos vinte anos, suas definições de TI foram publicadas pela Que em uma enciclopédia de termos tecnológicos e citadas em artigos do New York Times, Time Magazine, USA Today, ZDNet, PC Magazine e Discovery Magazine. Ela ingressou na Techopedia em 2011. A ideia de Margaret de um dia divertido é ajudar os profissionais de TI e de negócios a aprenderem a falar os idiomas altamente especializados uns dos outros.