Skip to content
uencoder

Hash Index

A hash index maps keys to buckets via a hash function, supporting O(1) equality lookups but not range queries or sorting.

Purpose

To understand the optimization scenarios for equality lookups and the limitations of hash indexes.

Mechanism

Compute hash of the index key → bucket position; in-bucket chains resolve collisions. Equality lookup is O(1) but <, >, and ORDER BY are unsupported. PostgreSQL supports hash indexes but defaults to B-Tree. Suited to KV stores and exact lookups.

Use cases

  • Equality lookup optimization
  • KV store indexing
  • Index type selection

Related tools

References