> For the complete documentation index, see [llms.txt](https://til.notdu.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.notdu.com/database/intro-to-database-systems/multi-threaded-index-concurrency-control/hash-table-latching.md).

# Hash table latching

Easy to support concurrent access due to the limited ways threads access the data structure.

-> All threads move in the same direction and only access a single page/slot at a time

-> Deadlocks are not possible

To resize the table, take a global latch on the entire table (i.e.., in the header page).&#x20;

\---

#### #1: Page latches

* Each page has its own reader-write latch that protects its entire contents
* Threads acquire either a read or write latch before they access a page.

#### #2: Slot latches

* Each slot has its own latch
* Can use a single mode latch to reduce meta-data and computational overhead.
