Readyset Weekly: Issue 14
How to Reduce Contention in High-Traffic Databases
As database traffic grows, so does the risk of contention and locking. These issues can silently stall reads, block writes, and trigger cascading slowdowns. Here's how to spot and fix contention before it chokes your system:
- Keep transactions short and scoped: Long transactions hold locks longer than necessary. Avoid wrapping reads and writes together unless needed. Commit early to release locks quickly. (Postgres & MySQL)
- Use the right isolation level: Higher levels (like
SERIALIZABLE) add protection but increase contention.READ COMMITTEDis often sufficient for OLTP workloads and reduces blocking or deadlocks. (Postgres & MySQL) - Reduce write hotspots: Contention often comes from multiple sessions updating the same row (e.g., counters or metadata). Batch writes, use advisory locks, or offload hot updates to a background queue. (Postgres & MySQL)
- Watch for heavyweight locks: Schema changes (like
ALTER TABLE) or certain advisory locks can block all table access. Usepg_locks(Postgres) orperformance_schema.metadata_locks(MySQL) to monitor lock types and durations. - Avoid SELECT FOR UPDATE unless required: Locking rows for reads can block concurrent queries. If you're not updating the data immediately, use optimistic concurrency or re-read before commit. (Postgres & MySQL)
- Add indexes to reduce gap locks: In MySQL with InnoDB, missing indexes can trigger gap locks on range queries. Use indexed
WHEREclauses to avoid locking extra rows.
Contended databases aren't just slow, they're unpredictable. Short transactions, partitioned workloads, and streamlined writes are key to scaling. In the next few weeks, we'll dig deeper into these strategies for high scale applications.
🔍 What We're Watching in the Database Ecosystem
Tiger Lake: A New Architecture for Real-Time Analytical Systems and Agents
TigerData introduced Tiger Lake offering seamless, real-time syncing between PostgreSQL hypertables and lakehouse storage like Iceberg on S3, enabling unified transactional and analytical workflows. It's a notable approach for teams building real-time pipelines on time-series or event data.
Optimal Indexing Strategies for PostgreSQL: Boosting Performance and Scalability
If you're interested in learning more about this week's main topic, this guide by Shiv Iyer is worth a look. It explores B-tree, GIN, BRIN, and specialized index types, plus strategies like partial and covering indexes. Real-world cases show how smart indexing can cut query time and reduce infrastructure costs.
PostgreSQL vs MySQL 2025: The Battle for Dominance in Open-Source Databases
A timely deep dive from SQLFlash comparing Postgres and MySQL across performance, cloud-native integration, and complex query support. PostgreSQL shines in ACID compliance, JSONB, and complex workloads, while MySQL excels in high-concurrency OLTP; an insightful read if you're weighing both for your next project.
In Case You Missed It
Don't Miss Our Upcoming Webinar on QueryPilot
This week, join Tanmay and Mike on Thursday at 10:30 am EST for an exclusive look at QueryPilot, our fully managed and automatic query identification, caching, and optimization platform.
Get Readyset Weekly in your inbox
One email a week — what shipped, what we learned, and what is worth reading.