liveBook · Manning

Hot row

As explained in The Coder Cafe

A hot row is a database row that receives disproportionately frequent access or updates and consequently becomes a contention or performance bottleneck.

A hot row is a database row modified frequently by concurrent transactions. Relational databases commonly lock the affected row, forcing competing updates to wait and increasing latency. section 6.11.1

Popular-post likes

A Likes table stores one counter per post, and each like runs an UPDATE that increments its post row. When a post becomes popular, concurrent requests serialize on that row, making the Like API slow. section 6.11.1

Common responses trade contention against freshness, reliability, or operational complexity:

  • Batch updates through a local counter and periodic background writes; this reduces database load but complicates retries, locking, and partitioning. section 6.11.1
  • Buffer writes in a write-optimized database and periodically transfer them to the relational database; this adds infrastructure and count latency. section 6.11.1
// /like/{post_id} handler
function like(postID string) {
  if randomInt(N) == 0 {
    increment(postID, N)
  }
}

A probabilistic increment reduces write frequency by applying an increment of N only when a random draw selects one request in N. section 6.11.1

How The Coder Cafe covers it

How deep it goes
Defines row-lock contention and compares batching, buffering, and probabilistic increments without fully specifying reliable background processing.
Examples
Uses a popular-post like counter, an UPDATE statement, and a randomized increment handler.
What it assumes
Assumes basic SQL, relational databases, concurrent transactions, and API latency concepts.
What you can do after
Diagnose lock contention and evaluate write-reduction strategies against freshness and operational complexity.
How it connects
Connects hot rows with transactions, row locking, relational databases, batching, and write-optimized databases.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Coder Cafe. The section links point to the parts of the book it draws on.