Logo

B-Tree Data Structure in Databases

How a Btree DS looks like:
Pasted image 20240915151137.png

Pasted image 20240915150558.png

DBs mostly use structured mappings like the Balanced Trees for quick operations, where

  • Insertion and Search take O(log n) operations
  • Each request is an I/O call
  • An ACK is sent for each call

To optimize this, we can:

  1. Reduce the number of I/O calls via batch processing combined queries. which reduces the number of ACK responses as well.
  2. Use some other type of specialized data structure for R/W

Log based Data Structrues

Pasted image 20240915151055.png

  1. Log or append type structures such as Linked Lists has fastest write operations O(1) but slow reads O(logn) Pasted image 20240915151343.png
  2. To overcome slow reads, sorted array can be used on "segments" where excess read operations does take place (i.e: building search indexes for these segments)

Alternatively, for making fast search operations to see whether data exists or not, use of Bloom Filters can be done, which can show whether a item exists.

© 2025 All rights reservedBuilt with DataHub Cloud

Built with LogoDataHub Cloud