Skip to content
StackDecode
System Design
4. Database FundamentalsAnimated

Hash Indexing

An index that maps a key to a location with a hash function.

The idea

Hash indexes give near constant-time exact lookups but cannot do ranges or ordering.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

App serversPrimary (writes)Replica 1 (read…Replica 2 (read…
  • client
  • gateway / proxy
  • service
  • cache
  • data store
  • queue / stream

Step one: add indexes and cache.

step:
1/4
at:
App servers
1/7

The green dot is a request moving through the system.

Step by step

  1. 1Hash the key
  2. 2Jump to the bucket
  3. 3Compare keys in the bucket
  4. 4Return the row

Where it is used

Exact-match lookups.

Watch out for

No range queries, and collisions need handling.

Related