logo
episode-header-image
Jul 2021
21m 46s

Should you go with an Optimistic or Pess...

Hussein Nasser
About this episode

MongoDB, Postgres, Microsoft SQL Server, or MySQL, or any other database manages concurrency control differently. There are two methods, pessimistic and optimistic, both have their pros and cons. Let explore how different databases implement this and what is the effect on performance/scalability.

This is often known as Optimistic vs pessimistic locking. Although I don't really like to use locking with this because it confuses the story.

0:00 Intro

2:20 What is Concurrency Control

6:00 Pessimistic Concurrency Control

14:50 Optimistic Concurrency Control


Resources

https://www.postgresql.org/docs/13/mvcc.html

http://source.wiredtiger.com/develop/architecture.html

https://docs.microsoft.com/en-us/troubleshoot/sql/performance/resolve-blocking-problems-caused-lock-escalation


Become a Member on YouTube

https://www.youtube.com/channel/UC_ML5xP23TOWKUcc-oAE_Eg/join


🔥 Members Only Content

https://www.youtube.com/playlist?list=UUMO_ML5xP23TOWKUcc-oAE_Eg


Support my work on PayPal

https://bit.ly/33ENps4


🧑‍🏫 Courses I Teach

https://husseinnasser.com/courses 

Up next
Yesterday
CPU and Kernel Page Faults
<p>Page faults occurs when the process tries to access a memory that isn’t backed by a physical page kernel raises a fault which loads a page. It happens on first access, stack expansion, COW, swap and much more. However it comes with a cost. </p><p><br /></p><p>In this episode o ... Show More
48m 37s
Oct 31
Amazon US-EAST-1 Outage in Details
On October 19 2025 AWS experienced an outage that lasted over a day, 10 days later we finally got the root cause analysis and we know exactly what caused the DNS to fail0:00 Summary 5:30 How did Dynamo lost its DNS?13:41 EC2 Errors 16:16 Network Load Balancer ErrorsRCA here https ... Show More
24m 26s
Oct 17
Graceful shutdown in HTTP
There are cases where the backend may need to close the connection to prevent unexpected situations, prevent bad actors or simply just free up resources. Closing a connection gracefully allows clients and backends to clean up and finish any pending requests. In this episode of th ... Show More
25m 49s
Recommended Episodes
Jun 2023
#420: Database Consistency & Isolation for Python Devs
See the full show notes for this episode on the website at <a href="https://talkpython.fm/420">talkpython.fm/420</a> 
56m 2s
May 2022
#366: Optimizing PostgreSQL DB Queries with pgMustard
See the full show notes for this episode on the website at <a href="https://talkpython.fm/366">talkpython.fm/366</a> 
1h 14m
Mar 2020
Easier Stream Processing On Kafka With ksqlDB
<div class="wp-block-jetpack-markdown"><h2>Summary</h2> <p>Building applications on top of unbounded event streams is a complex endeavor, requiring careful integration of multiple disparate systems that were engineered in isolation. The ksqlDB project was created to address this ... Show More
43m 36s
Sep 2023
Episode 486: High Performance PostgreSQL for Rails with Andrew Atkinson
If you love taking about databases, this is the episode for you. Ahead of the launch of his new book, High Performance PostgreSQL for Rails, Andrew Atkinson joined the show with special guest co-host, Pat Bair, to talk about why he wrote a book, why he focused on PostgreSQL and h ... Show More
31m 29s
Feb 2024
Postgres Replication at speed with PeerDB's Sai Srirampur
<p>Join Scott Hanselman as he sits down with Sai Srirampur, as they explore the intricacies of Postgres Replication and how it can be turbocharged using PeerDB. In the realm of databases, Postgres Replication is like a well-choreographed dance between servers. Sai takes us behind ... Show More
27m 6s
Dec 2019
Building The Materialize Engine For Interactive Streaming Analytics In SQL
<div class="wp-block-jetpack-markdown"><h2>Summary</h2> <p>Transactional databases used in applications are optimized for fast reads and writes with relatively simple queries on a small number of records. Data warehouses are optimized for batched writes and complex analytical qu ... Show More
48m 7s
Oct 2022
Going From Transactional To Analytical And Self-managed To Cloud On One Database With MariaDB
<div class="wp-block-jetpack-markdown"><h2>Summary</h2> <p>The database market has seen unprecedented activity in recent years, with new options addressing a variety of needs being introduced on a nearly constant basis. Despite that, there are a handful of databases that continu ... Show More
52m 4s
Aug 2021
#467: [INTRODUCING] Amazon MemoryDB for Redis
Amazon MemoryDB for Redis is the newest fully managed database service from AWS. Today, Nikki is joined by Zach Gardner, Specialist Solutions Architect at AWS, to introduce this new Redis-compatible, durable, in-memory database service. Learn why we built MemoryDB and dive into b ... Show More
29m 36s
Feb 2024
Episode 507: Stephen Margheim on SQLite in Ruby on Rails Applications
If you start a new Rails project today, you’re probably going to pick Postgres for your database. And if you have a ten year old Rails app, you might be using MySQL. But Rails ships with support for SQLite, a lightweight SQL database. Can that lightweight database be used to make ... Show More
31m 21s
Oct 2023
Reducing The Barrier To Entry For Building Stream Processing Applications With Decodable
<h2>Summary</h2> <p>Building streaming applications has gotten substantially easier over the past several years. Despite this, it is still operationally challenging to deploy and maintain your own stream processing infrastructure. Decodable was built with a mission of eliminat ... Show More
1h 8m