DELAPARRA
Index
Color
NL
Category: SQL

hash index

Explained by Updated

What is hash index?

hash index: Maps a hashed key to a location — fast for exact equality only, no ranges or sorting. A hash index stores a hash of each value and points to the matching rows. It is very fast for exact equality checks, such as looking up a session by its token. It cannot help with ranges, sorting or partial matches, because hashing destroys the order of values. WHERE token = 'abc' can use it; WHERE created_at > '2026-01-01' cannot.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about hash index

What should you keep in mind with hash index?

In PostgreSQL, hash indexes are a valid option for long values compared only for equality, where they can be smaller than a B-tree. MySQL's InnoDB uses its own adaptive hashing internally and only offers explicit hash indexes on memory tables. In practice, a normal B-tree index handles equality nearly as well and supports far more query types, so it remains the sensible default.

What does an example of hash index look like?

CREATE INDEX idx_sessions_token ON sessions USING hash (token);

At a glance

CategorySQL
Explained by
Updated

More SQL terms

All terms starting with H

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.