Earlier quoted context omitted.
> A btree is a kind of binary tree By definition a binary tree means there are two children per node. Binary is the one thing a b-tree is not .
Uhh. A b tree is a self balancing binary (search) tree.
How does database indexing work? (2008)
31–40 of 62 posts
Re: How does database indexing work? (2008)
#32Re: How does database indexing work? (2008)
#33If you want to see a dumb example of how you can implement indexing on top of a SQL database without it, I wrote a tutorial on implementing basic indexes [0] as part of a series on making a SQL database from scratch. And of course, Use the Index Luke is a great reference for the real world. [0] https://notes.eatonphil.com/database-basics-indexes.html [1] https://use-the-index-luke.com/
Re: How does database indexing work? (2008)
#34So how does a binary search work when the disk blocks are essentially a linked list as the top answer initially says? They just assume that it's possible to jump through a contiguous array of blocks for their later analysis but initially state blocks aren't necessary contiguous.
Re: How does database indexing work? (2008)
#35https://en.wikipedia-on-ipfs.org/wiki/Database_index
From "Hosting SQLite Databases on GitHub Pages" https://news.ycombinator.com/item?id=28021766 re: edgesearch, HTTP/3 QUIC UDP, :
> Serverless full-text search with Cloudflare Workers, WebAssembly, and Roaring Bitmaps https://github.com/wilsonzlin/edgesearch
>> How it works: Edgesearch builds a reverse index by mapping terms to a compressed bit set (using Roaring Bitmaps) of IDs of documents containing the term, and creates a custom worker script and data to upload to Cloudflare Workers
Re: How does database indexing work? (2008)
#36So how does a binary search work when the disk blocks are essentially a linked list as the top answer initially says? They just assume that it's possible to jump through a contiguous array of blocks for their later analysis but initially state blocks aren't necessary contiguous.
Re: How does database indexing work? (2008)
#37Earlier quoted context omitted.
Uhh. A b tree is a self balancing binary (search) tree.
Binary implies two. Both B-trees and BSTs exist in the universe of m-ary trees. A BST and a B-tree would be equivalent only if the branching factor of the B-tree was set to 2, but practically this is rarely the case with indexes, given that a higher branching factor is generally more favorable to lookup times (“block accesses”) since the hight of the B-tree is reduced as m increases.
Seems like it would be extremely odd to have a 2-2 btree, you’d just get a significantly more complicated BST no?
I’d figure you’d want to fill a cacheline with something typical-ish, so probably at least 4 (this way if you have 4 children and 3 keys, the keys are 8 bytes and the child links are straight pointers your node is 56 bytes and you can add some metadata e.g. a bitmap).
Apparently Rust’s BTreeMap is a 6-11 btree but I don’t know how they picked the branching factor.
Re: How does database indexing work? (2008)
#38You know what I would like to see (for learning)? A simplified project how indices, for example in b-tree, are stored in segment files.
Re: How does database indexing work? (2008)
#39Re: How does database indexing work? (2008)
#40You know what I would like to see (for learning)? A simplified project how indices, for example in b-tree, are stored in segment files.
This. I was hopeful that the linked article would explain how b-trees are practically used for indexes in DB engines. I already know what a db index is (databases 101 software eng) and why are they used, but would love a clear explanation of how are they implemented
It doesn't actually match low level implementations for a number of reasons. Such as the need to fix the page size the block fits in rather than the count of things in the block, and locking for concurrent access. But the data structure itself still looks the same.