logo
episode-header-image
Jun 2021
32m 38s

B-tree vs B+ tree in Database Systems

Hussein Nasser
About this episode


In this episode of the backend engineering show I'll discuss the difference between b-tree and b+tree why they were invented, what problems do they solve, and the advantages and disadvantages of both. I'll also discuss the limitation of implementing b-tree over b+tree and how Discord ran into a memory limitation using b-tree Mongo.


Check out my udemy Introduction to Database Engineering course https://husseinnasser.com/courses    Learn the fundamentals of database systems to understand and build performant backend apps


0:00 Data structure and algorithms

1:30 Working with large datasets

6:00 Binary Tree

8:30 B-tree

19:30 B+ tree

22:00 B-tree vs B+ tree benefits

25:00 MongoDB Btree Indexes Trouble

30:00 Summary

working with a billion row table (Members only)

https://youtu.be/wj7KEMEkMUE

indexing video

https://youtu.be/-qNSXK7s7_w

Discord moving from MongoDB to Cassandra

https://www.youtube.com/watch?v=86olupkuLlU

https://blog.discord.com/how-discord-stores-billions-of-messages-7fa6ec7ee4c7

MongoDB Indexes

https://docs.mongodb.com/manual/indexes/

Postgres Indexes

https://www.postgresql.org/docs/13/btree-implementation.html

btree code

https://www.cs.usfca.edu/~galles/visualization/BPlusTree.html

https://www.cs.usfca.edu/~galles/visualization/BTree.html



Support my work on PayPal https://bit.ly/33ENps4 

 Become a Member on YouTube

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

Courses I Teach https://husseinnasser.com/courses


Up next
Nov 24
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
Mar 2023
Moving up a level of abstraction with serverless on MongoDB Atlas and AWS
<p>The history of computing has been a story of moving up levels of abstraction: from hard-coding algorithms and directly manipulating memory addresses with assembly languages to using more natural language constructs in high-level general purpose languages to abstracting the har ... Show More
26m 8s
Sep 2021
S17:E9 - What are some database architectures and their use cases (Kyle Bernhardy)
In this episode, we talk about database architectures and some of their use cases, with Kyle Bernhardy, CTO of HarperDB. Kyle talks about what a database is, different types of databases, and when you might want to use one type of database over another. Show Links DevDiscuss (spo ... Show More
48m 31s
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
May 2023
The ORMazing show
Nick & KBall sit down with the brilliant Stephen Haberman to discuss all things ORMs! 💻🔍 From the advantages and disadvantages of ORMs in general, to delving into the intricacies of his innovative project Joist, which brings a fresh, idiomatic, ActiveRecord-esque approach to Ty ... Show More
1h 12m
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
Feb 2023
Shorten the distance between production data and insight
<p>Modern networked applications generate a lot of data, and every business wants to make the most of that data. Most of the time, that means moving production data through some transformation process to get it ready for the analytics process. But what if you could have in-app an ... Show More
20m 27s
Feb 2016
[MINI] k-d trees
This episode reviews the concept of k-d trees: an efficient data structure for holding multidimensional objects. Kyle gives Linhda a dictionary and asks her to look up words as a way of introducing the concept of binary search. We actually spend most of the episode talking about ... Show More
14m 11s
Jun 2021
A Candid Exploration Of Timeseries Data Analysis With InfluxDB
<div class="wp-block-jetpack-markdown"><h2>Summary</h2> <p>While the overall concept of timeseries data is uniform, its usage and applications are far from it. One of the most demanding applications of timeseries data is for application and server monitoring due to the problem o ... Show More
1h 6m
Jun 2021
Accelerating ML Training And Delivery With In-Database Machine Learning
<div class="wp-block-jetpack-markdown"><h2>Summary</h2> <p>When you build a machine learning model, the first step is always to load your data. Typically this means downloading files from object storage, or querying a database. To speed up the process, why not build the model in ... Show More
1h 5m