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 is an award-winning writer and educator known for her ability to explain complex technical topics to a non-technical business audience. Over the past twenty years, her IT definitions have been published by Que in an encyclopedia of technology terms and cited in articles in the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine, and Discovery Magazine. She joined Techopedia in 2011. Margaret’s idea of ​​a fun day is to help IT and business professionals to learn to speak each other’s highly specialized languages.