7
B-tree
Index
Supporting structure in external memory
maps keys to table row identifiers
Structure: Search Tree
Balanced
Highly branched
only sortable data types (using 'greater than' and 'less than' operations)
Search results are automatically sorted
Using a composite type
Improved access speed
support for integrity constraints
In this section, we will focus on one of the index types available in
PostgreSQL: the B-tree (B-tree). B-tree (B-tree). This is the most commonly
used index type in practice. Other types of indexes are covered later in this
course within the "Types of Indexes" section.
Like all indexes in PostgreSQL, the B-tree is a secondary structure — it
contains no information that isn't already available from the table itself, but it
does take up additional disk space. An index can be dropped and recreated.
Indexes are used to accelerate operations that involve a small part of the
table, such as retrieving a limited number of rows, and enforcing integrity
constraints (primary and unique keys).
Indexes map the values of indexed fields (search keys) to table row
identifiers. In the B-tree index, an ordered key tree is built, allowing quick
lookup of the desired key along with item pointers to row versions. For
example, numbers, strings, and dates can be indexed, but planar points
cannot (other index types are available for them). When indexing text
strings, you should take into account the specifics of sorting rules (for more
details, see course DBA2, topic 'Localization').
The B-tree is characterized by its balanced structure (constant depth) and
high branching factor. Although the tree's size depends on the indexed
columns, in practice, trees typically have a depth of no more than 4–5.