Understanding B-Trees: The Data Structure Behind Modern Databases

  Рет қаралды 557,356

Spanning Tree

Spanning Tree

Күн бұрын

Пікірлер: 510
@muno
@muno 9 ай бұрын
I really like how the little guys turn their heads to look at the thing you're talking about :)
@sid98geek
@sid98geek 9 ай бұрын
They are very cute and innocent.
@Scrolte6174
@Scrolte6174 9 ай бұрын
He does this in every video, Sherlock.
@Slitherman96
@Slitherman96 9 ай бұрын
@@Scrolte6174not everyone watches what you watch, Sherlock
@thezipcreator
@thezipcreator 9 ай бұрын
@@Scrolte6174 what does that have to do with anything? even if they do it in every video you can be appreciative of it?
@theowallace2310
@theowallace2310 9 ай бұрын
Having completed data structures and algorithms at an ABET accredited institution, I nod my head knowingly at this video.
@mooseyard
@mooseyard 9 ай бұрын
Beautiful explanation. I love the animations. As someone who's implemented a few persistent B-trees, allow me to point out a few more details: * This is the classic original B-tree. However, most databases use a B+tree, which is different in that the values are stored only in the leaves; keys in upper nodes just point to lower nodes. When a node splits, you don’t move the middle value up, it stays in one leaf or the other. * B-trees I’ve looked at, like SQLite, don’t have a fixed number of keys in a node. In real usage, keys and/or values are variable size, like strings, and the nodes are fixed-size disk pages (often 4kb.) The number of keys or values that fit in a node is highly variable. So instead you keep adding to a node until its size in *bytes* overflows a page, and then split. Some nodes might have a hundred keys, some might have only four. It doesn’t matter; the algorithms still work.
@yad-thaddag
@yad-thaddag 9 ай бұрын
Thank you! Very interesting!
@tylerpetrov8094
@tylerpetrov8094 9 ай бұрын
Learning something new everyday! Thanks for the info
@TheJamesM
@TheJamesM 8 ай бұрын
Yes, I was thinking about the latter point while I watched: "How do you decide on the number of keys per node? I guess you size it to just about fit into available memory, in order to minimize the number of expensive database queries." If the keys were of consistent size, you could just divide the memory you want to allocate by that size, but in most contexts I can see how it would be more practical to divide keys by size rather than by count. Do you get problems if e.g. you have adjacent large keys? Would that result in "wasted" space in a node?
@ZenoDovahkiin
@ZenoDovahkiin 8 ай бұрын
That makes sense, thanks!
@RomanShchekin
@RomanShchekin 7 ай бұрын
Quite useful comment to be honest. Real life scenarios are super useful in pair with the academic explanation!
@parthivsadhukhan5311
@parthivsadhukhan5311 23 сағат бұрын
Thanks for this amazing animated video with detailed explanation. It really helps me for understanding the functionality of B-Tree
@MaxPicAxe
@MaxPicAxe 9 ай бұрын
Lol that's actually my first time hearing about a b tree, looks awesome and elegant and simple
@thacium
@thacium 9 ай бұрын
Elegant indeed but far more complex than a binary tree. In this case you're trading simplicity for faster search time.
@paulstelian97
@paulstelian97 9 ай бұрын
@@thacium Some say that a special case of b-tree is equivalent to the red-black tree, another strategy which is, however, a binary search tree as well.
@TheWizardGamez
@TheWizardGamez 9 ай бұрын
Knock on wood before your up at 2 AM on a Red Bull and adderall fueled binge trying to figure out how to shave off 1 ms of process time.
@ronak212
@ronak212 8 ай бұрын
Ain't nowhere near simple but magnificent for sure
@phoneix24886
@phoneix24886 22 күн бұрын
Awesome and elegant yes. Simply, definitely not.
@asishreddy7729
@asishreddy7729 9 ай бұрын
Such a simple but beautiful animation! So many channels do such complex animations but they do not realise simple animations can be so beautiful.
@davidbatista1183
@davidbatista1183 9 ай бұрын
Has a Wall-E kind of feeling 😊
@SantiagoArizti
@SantiagoArizti 8 ай бұрын
I found it confusing that the nodes left undimmed were the ones we were supposed to pay attention to. Didnt you?
@nikilragav
@nikilragav 5 ай бұрын
@@SantiagoArizti no, but I found it confusing that he would undim parts of the tree as he said the sentence rather than just undimming the whole section together
@0tobsam0
@0tobsam0 6 ай бұрын
I have an exam on algorithms and data structures in 3 days and this video manages to break down hours of lectures into 12 minutes... Incredibly helpful
@TheSilentknight.1
@TheSilentknight.1 9 ай бұрын
Just saying thank you from behalf of the community for those amazing visualization teaching vids and for the quality you put in them
@amongusztav655
@amongusztav655 8 ай бұрын
I didn't understand B-trees from university classes but now I do. 3 days before exam. Thank you!
@vastabyss6496
@vastabyss6496 8 ай бұрын
how did it go?
@amongusztav655
@amongusztav655 8 ай бұрын
@@vastabyss6496 I passed it but I only got a kettes/elégséges so I'm going to attend the repair exam
@Lemetrriss
@Lemetrriss Ай бұрын
how did it go?
@youarethecssformyhtml
@youarethecssformyhtml 15 күн бұрын
how did it go?
@amongusztav655
@amongusztav655 15 күн бұрын
@youarethecssformyhtml I got a 5 (best grade in Hungary)
@seductivewalrus5587
@seductivewalrus5587 Ай бұрын
Thank you for doing the service of posting this publicly and free. This cleared up for me in 12 minutes at absolutely no cost. Meanwhile, the 75 minute lecture I paid thousands of dollars for left me more confused than inspired to apply this very important data structure to my side project.
@LordHonkInc
@LordHonkInc 8 ай бұрын
Man, I remember having balancing B-Trees as assignments in my CS exams and failing to get the right answers. This video does a much better job of explaining it than any class I took in university in a fraction of the time we spent learning it. Thanks for finally getting me to understand👍
@esra_erimez
@esra_erimez 9 ай бұрын
This is a great video. Normally, databases do not store data in internal nodes, only leaf nodes and function as intermediate pointers. Leaf nodes on the other hand contain the actual data entries or pointers to those data entries. Additionally, most databases have pointers to neighboring leaf nodes. By the way, these pointers to neighboring leaf nodes help lot with solving concurrent operations on the B-Tree.
@sohampatel5166
@sohampatel5166 9 ай бұрын
yeah those are known as B+ Trees
@mooseyard
@mooseyard 9 ай бұрын
A different approach to concurrency is copy-on-write, where instead of changing a node in place you make a copy of it with the changes. This means changes don’t affect any concurrent readers since nodes are immutable. However, any nodes that point to the modified node also have to be updated to point to the new one, which means a change spreads up to the root node. (This may sound wasteful, but in practice you can modify new nodes in place because no one else can see them. So a node only has to be copied once during any transaction.) In this type of tree you can’t have links between siblings because you’d end up having to copy all the siblings too. Instead, when you’re going down the tree you keep a breadcrumb trail, your path, and to get to a sibling you look up, move one child, and go back down. This type of tree is used by CouchDB and LMDB, among others.
@nikilragav
@nikilragav 5 ай бұрын
when do you get concurrent operations on the same DB? How is it not queued?
@esra_erimez
@esra_erimez 5 ай бұрын
@@nikilragav There is a paper titled "Efficient locking for concurrent operations on B-trees" by Bing Yao & Philip Lehman that was the break through
@nikilragav
@nikilragav 5 ай бұрын
@@esra_erimez Thanks. Is the idea that you have multiple threads accessing the same db? No queue?
@Eckster
@Eckster 9 ай бұрын
So good, the easiest explanation for such a common data structure I've seen. It's crazy how we teach all these other trees in computer science classes but leave out the most used one. I especially appreciated the performance advantages against binary trees being explained.
@neilcarrier1620
@neilcarrier1620 9 ай бұрын
I agree; it's a good example of how different measures of efficiency lead to different solutions.
@FutureAIDev2015
@FutureAIDev2015 9 ай бұрын
This channel has been a massive help for me in understanding the concepts in my algorithms class well enough to actually pass the assignments.
@isbestlizard
@isbestlizard 9 ай бұрын
MIT opencourseware also do a great series on algorithms plus the professor is SUPER CUTE he's the dude into origami
@MichaelChin1994
@MichaelChin1994 9 ай бұрын
Fed up with my living room being a mess, I decided to watch this. Oddly think it's going to help
@KaiHenningsen
@KaiHenningsen 9 ай бұрын
Keep the mess in a b-tree?
@Y2Kvids
@Y2Kvids 9 ай бұрын
use c trees
@azizayari252
@azizayari252 9 ай бұрын
Well you're gonna need to sort it in an ascended or descended order first
@KaiHenningsen
@KaiHenningsen 9 ай бұрын
@@azizayari252 What for? That happens automatically when putting it in the tree.
@Shake_Well_Before_Use
@Shake_Well_Before_Use 9 ай бұрын
​​Christmas?a​@@Y2Kvids
@offtheball87
@offtheball87 9 ай бұрын
I've just started the CS50 AI course as background learning at work, and imagine my surprise to hear this voice again. I really enjoy your teaching style, and I'm so glad to have found more content from you!
@rohitannamaneni7784
@rohitannamaneni7784 Ай бұрын
This is the most simple and efficient intuition I have seen to understanding B-Trees. Really appreciate it
@The_Pariah
@The_Pariah 6 ай бұрын
This is a REALLY good series and I wish Spanning Tree would post more content. They have a fantastic layout, information is conveyed well, and it's thorough but not so technical that people don't understand it. Please make more content. It's hard to find solid video series like this that explain important programming concepts. 10/10
@caleb765landis
@caleb765landis 9 ай бұрын
This is literally the best data structure explanation video I’ve ever seen
@mskiptr
@mskiptr 9 ай бұрын
I more or less knew how B-trees work already, but this was just such a neat refresher that I now want to implement it (maybe together with a couple of formal verification proofs, to show that all these properties are always maintained)
@peterpesch
@peterpesch 8 ай бұрын
Wow! Great explanation! Basically the same as how we learned it 45 years ago, but with these animations it takes much less time. Back than, the professor was running around with chalk to change the diagrams on the chalkboard ...
@codermomo1792
@codermomo1792 6 ай бұрын
OG programmer All respect
@kamalzubairov2344
@kamalzubairov2344 9 ай бұрын
Awesome explanation. I always had the feeling that I almost understand how B-trees work, but I wasn't quite there yet. This video showed me the things that I was missing. Thank you!
@Browsinghard
@Browsinghard 8 ай бұрын
Very elegant explanation and animation, you cleared up my misunderstandings from when I just read about b-trees. Your little blob dudes are great communicators!!
@GH-oi2jf
@GH-oi2jf 6 ай бұрын
"B-trees" please. Capitalized.
@RitaZ0518
@RitaZ0518 21 күн бұрын
very clearly and plainly explanation, very impressive👏🏻looking forward to more videos🙏🏻
@IvanToshkov
@IvanToshkov 9 ай бұрын
I love your videos. You somehow always manage to hit the right amount of details. Great job!
@69k_gold
@69k_gold 9 ай бұрын
This is the best visual learning channel for CS on KZbin
@yoyoyo-hw2lc
@yoyoyo-hw2lc 4 ай бұрын
Absolutely Brilliant Explanation and Animation. I had never encountered B-Trees and became interested in them because they are not in A-level Computer Science Exam Boards. This video taught me B-trees in just 12 minutes and encouraged me to build my own in C++.Thanks!
@paulstelian97
@paulstelian97 9 ай бұрын
There's an additional bonus -- nodes tend to be able to fill in some special size, like a disk block or a cache line, which allows further efficiency when doing comparisons for a search. That's why for some applications it's objectively better than even the red-black tree.
@mrinalde
@mrinalde 8 ай бұрын
Thanks!
@vibhavkadavakollu4669
@vibhavkadavakollu4669 2 ай бұрын
You're awesome bro, I couldn't understand this concept from 1 week of lectures, but you just explained it in 10 minutes.
@Crafterchen2
@Crafterchen2 4 ай бұрын
This helped me a lot! The Animations are really well done and help explaining the thing you're talking about. This is how explanatory videos should be done!
@spliterator1981
@spliterator1981 9 ай бұрын
I'm listening to "designing data intensive applications", and wasn't quite able to visualize a b-tree through audiobook only. This really cleared everything up. Thanks!
@chriscsld7278
@chriscsld7278 Ай бұрын
one of my philosophy of learning is visualization, thank you Mr for guiding those who came here for understanding
@PeterKluth
@PeterKluth Ай бұрын
It's Brian from cs50! Hahaha! Spent so many hours listening to his walkthroughs of the problem sets, did not expect to stumble upon his YT channel
@professorpoke
@professorpoke 9 ай бұрын
Proud to say that I am following this channel since when it has less than 100K subscribers.
@MichaelDeHaven
@MichaelDeHaven 9 ай бұрын
Dude, I just found it yesterday! It's a great channel and deserves the growth.
@srivarsha9574
@srivarsha9574 2 ай бұрын
The best video out in the internet for B Tree!! Thank you so much!!
@yao-z2t
@yao-z2t Ай бұрын
This is the best video I have watched about data structure. It's so cute and thank you for making this video!!!
@AndySterkowitz
@AndySterkowitz 4 ай бұрын
Excellent video. Well done on articulating this in such an easy to understand way.
@willowtreeangel
@willowtreeangel 5 ай бұрын
Ah, I always struggled with B-trees during my Database Design class. If I had this video, I wouldn't have struggled at all! Fantastic work, very informative.
@sripriyansvbsbtskanchibhat9152
@sripriyansvbsbtskanchibhat9152 6 ай бұрын
It's really an awesome way of explanation ruling out drawing the trees and explaining...no words to appreciate...thank you for making such wonderful videos...great work
@leo_bonifacio
@leo_bonifacio 8 ай бұрын
Thank you a lot for the beautiful explanation of this topic! I always encounter the question about indexing algorithms and used data structures in databases for a data engineer position. So this video helps a lot in understanding b-trees. Thanks again!
@ivanthomas8503
@ivanthomas8503 9 ай бұрын
you published this at the exact right time I have a final exam today and this will be on it and I needed to study up on it.
@SpadeZ777
@SpadeZ777 Ай бұрын
What an amazing way to explain B-Trees I really like it!!
@richardwilliamsmusic
@richardwilliamsmusic 7 ай бұрын
Phenomenal teaching! please do more computer programming related concepts, love this!
@nithssh
@nithssh 9 ай бұрын
I was looking to implement btrees a while back and all the literature on it were conflicting and varying. I like how you handled all the variances subtely. This is a great video, the definitive one on btrees for sure. Cheers.
@GH-oi2jf
@GH-oi2jf 6 ай бұрын
The term is "B-tree."
@jensdit
@jensdit 9 ай бұрын
Awesome video! Just one clarification: database systems typically use B+-trees rather than B-trees to allow for ISAM (range search on leave nodes).
@HolyC-xs2zj
@HolyC-xs2zj 9 ай бұрын
So well animated, so simply and informatively explained. Thank you!
@achyutkayastha4248
@achyutkayastha4248 2 ай бұрын
This is how real learning should be done! Great content! I don't remember if I learned it full when I did in college.
@arkan7rb
@arkan7rb 4 ай бұрын
thank you sir for most wonderful explanation for b trees i have ever seen i well share ur vid to friends it deserves to be seen
@kamgarostand4343
@kamgarostand4343 2 ай бұрын
Great Video! The animations were more than welcome!
@freebirdyaoyao
@freebirdyaoyao 3 ай бұрын
Fantastic illustration for one of the most complex topic in computer science education. I wish I get to learn this video when I was at university .
@mooldar
@mooldar Ай бұрын
Outstanding explanation, thanks for the animations 🌟
@docjoesweeney
@docjoesweeney 9 ай бұрын
Ha! Thanks for this. I remember coding b trees waaaay back in the early 80s. Gawd I'm old.
@crosswalker45
@crosswalker45 9 ай бұрын
Which language do you used to code in 80s?
@poopytowncat
@poopytowncat 9 ай бұрын
_"early 80s"_ OK boomer! I'm approaching my "early 80's" and I remember coding stuff waaaay waaaay back in the "early 70's" on IBM punch cards.
@docjoesweeney
@docjoesweeney 9 ай бұрын
@@crosswalker45 vb, ada , assembler (for 6809), vulcan then dbase and clipper, kman, pascal... likely a few others i am too to recall.
@crosswalker45
@crosswalker45 9 ай бұрын
@@docjoesweeney I always wonder how people in 80s, used to write the code. I'm assuming there won't be any proper documentation or persistent internet connection for that matter.
@docjoesweeney
@docjoesweeney 9 ай бұрын
@@crosswalker45 dig up old editions of Dr Dobbs magazine. I am sure someone would have scanned them for prosperity.
@pesetskyps
@pesetskyps 2 ай бұрын
Bravo for traversing the complexity into simplicity 🎉
@ThotasaiKiran-xg8kt
@ThotasaiKiran-xg8kt 24 күн бұрын
It is very impressed and very very excited I haven't seen this type masterpiece I really love and I am looking forward to see more videos on cse course 😊😊😊😊❤❤
@ameenbari6758
@ameenbari6758 2 күн бұрын
the algorithm is elegant, so is your explanation!
@mihiragrawal6174
@mihiragrawal6174 3 ай бұрын
Beautiful animations and explanation. Really really thanks for this
@Lidonnn
@Lidonnn 6 ай бұрын
With your explanation, it looks really simple and elegant. Thanks a lot!
@saviofernandes5263
@saviofernandes5263 8 ай бұрын
Stumbled upon this video by accident and I knew I heard that voice before 😂Nice to know that you have your own KZbin channel now, Brian!
@giovanni_siciliano_ivano
@giovanni_siciliano_ivano 8 ай бұрын
is the first time i subscribe to a channel after i saw 5 seconds and skipped a couple of minutes after other 3 seconds. All your effort needs to be encouraged
@bokistotel
@bokistotel 2 ай бұрын
I have no words, just amazing!
@HPerrin
@HPerrin 9 ай бұрын
This is a great explainer video. Very easy to follow and I love the little robot guys.
@rafazieba9982
@rafazieba9982 8 ай бұрын
I've been a professional developer for 17 years now. A really good one. I always knew that BTrees are used to store database indexes and that they reduce search complexity to logarithm. I knew how binary trees and AVL trees work. I always wondered how BTrees work. I was too lazy to do the reading. Now I know. Thank you.
@walttroianivargas5200
@walttroianivargas5200 5 ай бұрын
Something similar happened to me, I knew the tool and used it but i didn't fully grasp it. Now that I'm making my own SQLite in Rust is really helpful!
@JohnSmith-op7ls
@JohnSmith-op7ls 5 ай бұрын
Unless you’re writing a DBMS, it’s super unlikely you need to know how b-trees work
@Bess_Gates
@Bess_Gates 2 ай бұрын
Thank you man , it’s my first time to understand this
@mrunknown5087
@mrunknown5087 6 ай бұрын
the way you teach is magnificent. keep it up buddy
@manojalayer
@manojalayer Ай бұрын
Amazing quality of presentation.
@fazil_8298
@fazil_8298 16 күн бұрын
Thank you for the great video! I love your content. I have a suggestion if that's alright. The color for numbers in resting state(blue) is reused for showing the highlighted numbers as well. When you grey out the numbers in each step, I intuitively thought that you are highlighting the greyed out numbers where in fact the ones left in blue were the highlighted numbers that I had to focus on. If you could have different color for highlight vs resting state of the numbers, it will be much more clearer. Thanks again.
@reza.kargar
@reza.kargar 3 ай бұрын
Best B-Tree explanation ever!
@vt_blurry2443
@vt_blurry2443 8 ай бұрын
Beautiful animations with a very clean explanation! Thank you sir!
@allanatal
@allanatal 9 ай бұрын
That video was so well made that even I could understand. Code this algorithm is another story, though.
@keobkeig
@keobkeig 3 ай бұрын
Best explanation of btrees I’ve ever seen
@jiwan88
@jiwan88 9 ай бұрын
Amazing video and explanation.
@ambarishsarkar1820
@ambarishsarkar1820 Ай бұрын
Beautiful explanatoin with great animation. Keep it up!
@richbronson9082
@richbronson9082 3 ай бұрын
Great explanation. I really left feeling like I understood.
@angkhoi5740
@angkhoi5740 8 ай бұрын
awesome, never understood this tree until now. Thanks a lot :)
@sharma7889
@sharma7889 2 ай бұрын
the best channel i've ever visited...all you need is some promotion..and then lets see where you will be!!All the best!!
@yagamilight120
@yagamilight120 9 ай бұрын
You're a legend bro... Hope u live 100 more years
@aV5d9nlUBQ9
@aV5d9nlUBQ9 9 ай бұрын
Your videos are awesome. Thanks, Brian!
@HudsonGTV
@HudsonGTV 2 ай бұрын
Important timestamps. **Insertion Scenarios:** 5:08 - Basic Insertion 6:20 - Another Basic Insertion with Root partially full 6:50 - Insertion with full root **Deletion Scenarios:** 7:48 - Basic Deletion 8:15 - Deletion of Key in Node w/Min Count (take sibling key - it becomes new separator - old separator is moved to original node where deletion occurred) 9:42 - Deletion of Key when Sibling Nodes are also at Minimum Count (merge sibling and separator together into single full node) 10:10 - Same as above, but causing Parent node to fall below Minimum Count as well 10:28 - Deletion of key from middle of tree (new separator needed - either take largest val in left subtree, or smallest val in right subtree - may need to take key from sibling or merge 2 nodes together if it causes child node to fall below min key count)
@TheYakup85
@TheYakup85 6 ай бұрын
That's the great explanation I have ever seen. Thank you so much!
@aliveli8650
@aliveli8650 9 ай бұрын
Very good explanation!! Congrats!! Keep it going!
@caterpieasmr2699
@caterpieasmr2699 6 ай бұрын
Thank you so much, i have an exam that includes b-trees, but ALL the explanations are plain text with a lot of nonsensical expressions and variables. This is so simple and straightforward compared to that c:
@motonoob-i2d
@motonoob-i2d 6 ай бұрын
Really well done. Wish I had access to content like this when I went through school
@alessio1253
@alessio1253 4 ай бұрын
You may have just saved my exam. Incredible video
@fdsfkdj
@fdsfkdj 8 ай бұрын
Thank you for directly going into the subject.
@chanm01
@chanm01 6 ай бұрын
Dude, these animations are sick.
@Lost_S
@Lost_S 6 ай бұрын
Omg I love you this is an incredible review of how these trees work
@mert.yksl03
@mert.yksl03 Ай бұрын
What an amazing explanation! Love it
@konstantinzolotarev
@konstantinzolotarev 8 ай бұрын
Surer clear and simple explanation! Thank you very much for your time and effort!
@BlazeShomida
@BlazeShomida 14 күн бұрын
1:57 in a bit more technical way, the branching factor (k) of a binary tree is 2 and the search space is represented as 1 - 1/k so basically a binary tree reduces search space to 50% where as a ternary tree (3) would only reduce to 67%, meaning we have more to search on a miss. Although there a special case where k is 1, for that we just walk through linearly like an array.
@wissiw5276
@wissiw5276 9 ай бұрын
i wish i could have a teacher that utilizes simple animations like these in class, the visualisation makes it so clear
@jindrichsirucek
@jindrichsirucek 8 ай бұрын
Awsome expl🙏🙏🙏 For me personaly at first was confusing that you dim not related part, I would intuitively expect get brighter the part where change was happening instead of dimming the rest.. Great work, thx for expaining 🙏
@slobberingdog72
@slobberingdog72 8 ай бұрын
Nice and easy explanation. Great job !!
@shubhamraj5557
@shubhamraj5557 8 ай бұрын
Great video please continue making these
@Intense_Cloud
@Intense_Cloud 8 ай бұрын
The "monitos" (cute animations) got me engaged to watching, among the interesting information presented/narrated. Great video!🎉😊
@SpockKaDeddy
@SpockKaDeddy 9 ай бұрын
Thank God your back ❤❤❤❤
@jerry-kz1tj
@jerry-kz1tj Ай бұрын
This videos helps undertands hows b-trees works thanks!
@darylbeaumont8855
@darylbeaumont8855 7 ай бұрын
Greaty video! Presented well and easy to understand. :)
@imveryangryitsnotbutter
@imveryangryitsnotbutter 9 ай бұрын
2:36 When designing a b-tree, how does the programmer determine what the maximum amount of keys in a node should be? For which applications is it appropriate to set the limit to 2, and which applications should have a limit of hundreds? There's a happy medium somewhere, but how is that happy medium calculated?
@IvanToshkov
@IvanToshkov 9 ай бұрын
It depends on your application. For example for a database system I'd go with a node size that can fit in L1 cache of the processor. Or maybe use the filesystem block size? And then delete the size by the size of an element to figure out the number of elements in a block. And then test, modify and repeat.
@Jason9637
@Jason9637 9 ай бұрын
The best way is to simply try them and see what works best.
@tactic00l
@tactic00l 9 ай бұрын
In practice comparisons tend to be very cheap compared to main memory access, combine that with the fact that the processor loads memory in lines of cache (64 bytes) you want to pick a node size at least 64 bytes large. The sequential prefetcher makes 128 bytes a good option too
@capability-snob
@capability-snob 9 ай бұрын
There are a variety of locality effects that can come into play. tactic00l mentioned cache line size which is a good minimum for in-memory b-trees. You might also size them to fit nicely into a block on disk, so you can make more comparisons for each disk read operation. There are subtler impacts from prefetch logic and alignment that might be worth measuring, depending on your microarchitecture or allocator respectively. some considerations might not be just about latency of accessing memory; depending on your concurrency model, likelihood of paging, data structures you are storing as values etc you might find reason to increase or decrease the number of keys stored in a node.
@GH-oi2jf
@GH-oi2jf 6 ай бұрын
It's "B-tree." The point of a B-tree is to reduce accesses to secondary storage. If your B-tree resides on disk, then the node certainly should be as large as can fit in a sector, because you don't want to be reading disk space that you don't use. Whether it should be two sectors, or four, or something else, depands on the characteristics of the device and your judgment about what will work well. If your entire B-tree will reside in RAM, then you might as well use a 2-3 tree, which is the minimum B-tree.
@live_first
@live_first Ай бұрын
I remember working in the ANSII MUMPS language / database in the 80s. A very easy to use and poweful deveopment system, way ahead of its time, which overtme was developed with both SQL and OO front ends by InterSystems
@phoneix24886
@phoneix24886 22 күн бұрын
If the interviewer askes me to code up a B tree in front of him, I will be so dead lol
Database Indexing for Dumb Developers
15:59
Laith Academy
Рет қаралды 88 М.
How Dijkstra's Algorithm Works
8:31
Spanning Tree
Рет қаралды 1,4 МЛН
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
8 Data Structures Every Programmer Should Know
17:09
ForrestKnight
Рет қаралды 267 М.
AI Is Making You An Illiterate Programmer
27:22
ThePrimeTime
Рет қаралды 222 М.
Write a database from scratch | Episode 6, Index Storage Manager
19:15
Top 7 Data Structures for Interviews Explained SIMPLY
13:02
Codebagel
Рет қаралды 257 М.
The hidden beauty of the A* algorithm
19:22
Polylog
Рет қаралды 923 М.
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
3 Types of Algorithms Every Programmer Needs to Know
13:12
ForrestKnight
Рет қаралды 526 М.
Transformers (how LLMs work) explained visually | DL5
27:14
3Blue1Brown
Рет қаралды 4,6 МЛН
Why Are Threads Needed On Single Core Processors
16:07
Core Dumped
Рет қаралды 252 М.
Naming Things in Code
7:25
CodeAesthetic
Рет қаралды 2,3 МЛН
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН