1 00:00:00,060 --> 00:00:01,540 ‫What is going on, guys? 2 00:00:01,560 --> 00:00:08,850 ‫My name is Hussein, and in this video, I want to talk about how database's store information in the 3 00:00:09,090 --> 00:00:13,020 ‫disk, and that was a question asked by one of you guys. 4 00:00:13,020 --> 00:00:19,050 ‫And it was a very good question because usually we take things for granted. 5 00:00:19,290 --> 00:00:25,980 ‫But when you really understand is you feel pity for the computer that does the job for you because. 6 00:00:26,370 --> 00:00:27,300 ‫Oh, my God. 7 00:00:27,420 --> 00:00:27,800 ‫Right. 8 00:00:27,840 --> 00:00:29,220 ‫You appreciate it. 9 00:00:29,310 --> 00:00:29,880 ‫Right? 10 00:00:29,880 --> 00:00:33,960 ‫When you start washing the dishes, you know how hard that job is, right? 11 00:00:34,380 --> 00:00:39,900 ‫Thinking dishes and especially, if you like, cooked an egg and you forgot the plate for a day and 12 00:00:39,900 --> 00:00:46,380 ‫then you come the next day and and those that yellow yolk thingy, I don't know what they call them. 13 00:00:46,380 --> 00:00:47,370 ‫English, right. 14 00:00:47,490 --> 00:00:52,210 ‫The yellow thing, they get stuck in the plate and you need to work really hard then. 15 00:00:52,420 --> 00:00:55,650 ‫And you understand how dishwashing is really hard. 16 00:00:55,890 --> 00:00:56,940 ‫Same thing with a computer. 17 00:00:56,940 --> 00:01:00,530 ‫A computer is not dishwashing per say, but kind of similar. 18 00:01:01,320 --> 00:01:02,190 ‫I'm rambling. 19 00:01:02,190 --> 00:01:04,460 ‫I know you guys. 20 00:01:04,650 --> 00:01:13,530 ‫The idea here is to understand how databases really store information on disk. 21 00:01:14,040 --> 00:01:14,660 ‫All right. 22 00:01:14,670 --> 00:01:18,990 ‫So it is extremely complicated thing. 23 00:01:19,590 --> 00:01:22,350 ‫And let's talk about a little bit this. 24 00:01:22,560 --> 00:01:25,410 ‫I'm not going to be adding graphics or anything. 25 00:01:25,410 --> 00:01:27,360 ‫Just imagine what you mean, guys. 26 00:01:27,600 --> 00:01:30,780 ‫See, follow my hands, because that's what I'm going to use here. 27 00:01:30,930 --> 00:01:37,220 ‫I'm going to make another video detailing went with virtual board and all that jazz. 28 00:01:37,230 --> 00:01:39,170 ‫But here's the thing, guys. 29 00:01:39,420 --> 00:01:42,410 ‫Imagine you have a beautiful table. 30 00:01:42,430 --> 00:01:43,260 ‫Has to be beautiful. 31 00:01:43,260 --> 00:01:45,840 ‫If it's not a beautiful, then you have a problem. 32 00:01:45,960 --> 00:01:54,630 ‫But if it's a table and let's say for simplicity, there is only one field and that field is an integer. 33 00:01:55,560 --> 00:02:03,930 ‫Thirty two bit, let's say, right there, that's what I'd bet a bet, which is for whites, not not 34 00:02:03,960 --> 00:02:04,280 ‫eight. 35 00:02:04,620 --> 00:02:06,030 ‫OK, so. 36 00:02:07,260 --> 00:02:15,360 ‫You have an integer right field, so and that's four bytes, so if I insert one rule, any number. 37 00:02:16,370 --> 00:02:21,790 ‫Between one and two billion, I guess that's the maximum 32 bit injury you can have, right? 38 00:02:22,070 --> 00:02:27,350 ‫It's going to take four bytes of space and we're going to talk about what space really means. 39 00:02:27,770 --> 00:02:34,530 ‫So if I insert over here four bytes, it's another four bytes, another four bytes, another four. 40 00:02:34,570 --> 00:02:39,860 ‫But how does this really is stored in disk? 41 00:02:39,860 --> 00:02:40,270 ‫Right. 42 00:02:40,910 --> 00:02:43,670 ‫And I'm going to explain this in two fashion. 43 00:02:44,180 --> 00:02:55,510 ‫How is stored in SSD and how is stored in HDD hard disk drive, which is these rotating thingee? 44 00:02:56,270 --> 00:02:56,660 ‫All right. 45 00:02:56,660 --> 00:02:58,190 ‫How do you like this sound effect guys on. 46 00:02:58,250 --> 00:03:02,810 ‫So, yeah, so we have a spinning disk and this is the and there is like a little bit different how 47 00:03:02,810 --> 00:03:04,210 ‫they stored information. 48 00:03:04,220 --> 00:03:12,320 ‫So let's start with the hard disk drive, which is a spinning disk, the hard disk drive that it is 49 00:03:12,320 --> 00:03:15,080 ‫obviously a platter, which is a circle. 50 00:03:15,080 --> 00:03:15,500 ‫Right. 51 00:03:15,740 --> 00:03:20,570 ‫And there is sectors, pork and each sector. 52 00:03:21,680 --> 00:03:30,890 ‫Present information, and each sector has a little bit of luck in it, and these are tagged and identified 53 00:03:30,890 --> 00:03:34,770 ‫uniquely for every single sector that is in the hard drive. 54 00:03:34,820 --> 00:03:42,470 ‫So you would say, OK, Blätter, number one, track number seven, sector number five and block number 55 00:03:42,560 --> 00:03:43,040 ‫two. 56 00:03:43,370 --> 00:03:51,560 ‫And that gives you exactly a block, which is a block of disk that corresponds to a number of bytes, 57 00:03:52,010 --> 00:03:53,630 ‫let's say five hundred and twelve bytes. 58 00:03:53,760 --> 00:03:55,700 ‫OK, so. 59 00:03:56,670 --> 00:04:02,790 ‫Go back to our logical representation off the table, if I insert four by this integer, like number 60 00:04:02,790 --> 00:04:04,160 ‫seven, which is four by four, right. 61 00:04:04,560 --> 00:04:05,940 ‫That's the beautiful thing here. 62 00:04:06,240 --> 00:04:09,000 ‫If you're number seven, you're going to reserve four bytes. 63 00:04:09,600 --> 00:04:14,340 ‫If you're insert number two million, you're going to reserve for it doesn't matter, right. 64 00:04:14,430 --> 00:04:16,740 ‫Because it's old zero zero one zero zero zero zero zero. 65 00:04:16,770 --> 00:04:18,120 ‫It's all four bytes. 66 00:04:18,390 --> 00:04:24,780 ‫And that four bytes will be stored in that given block. 67 00:04:25,300 --> 00:04:27,060 ‫OK, and. 68 00:04:28,300 --> 00:04:34,780 ‫Codes, that block is 512 and you start for four bytes, that kind of waste, right, you cannot jump 69 00:04:34,780 --> 00:04:37,210 ‫to another block and start another four bytes. 70 00:04:37,660 --> 00:04:38,060 ‫Right. 71 00:04:38,320 --> 00:04:39,880 ‫You have to insert another row. 72 00:04:40,150 --> 00:04:42,970 ‫And here's what the data is smart. 73 00:04:43,270 --> 00:04:51,010 ‫The database says, wait a second, this table is reserving this block so far and it's going to put 74 00:04:51,010 --> 00:04:55,840 ‫the next four by the next integer next to that four byte. 75 00:04:55,850 --> 00:05:01,300 ‫So it's going to be adjacent to it so they can fit in the same block and you keep inserting something 76 00:05:01,300 --> 00:05:04,690 ‫in something until that 512 is completely filled. 77 00:05:05,750 --> 00:05:14,570 ‫Right, and you might say, wait a second, how do I know if I want to pull row number one to go to 78 00:05:14,570 --> 00:05:15,370 ‫that block? 79 00:05:16,220 --> 00:05:20,570 ‫That's how the database stores stuff that their base will say. 80 00:05:20,960 --> 00:05:23,320 ‫OK, Roe, no. 81 00:05:23,990 --> 00:05:31,700 ‫There is a unique identifier for the road and it could be that primary key if that field happened to 82 00:05:31,700 --> 00:05:32,350 ‫be primary. 83 00:05:32,660 --> 00:05:36,830 ‫So that particular number points. 84 00:05:36,830 --> 00:05:42,680 ‫There is metadata in the database that says, hey, this I want, for example, row number one, wrong 85 00:05:42,680 --> 00:05:45,050 ‫number one, have some information next to it. 86 00:05:45,320 --> 00:05:49,630 ‫Sector seven, block eight, track three. 87 00:05:50,030 --> 00:05:55,520 ‫And that information is what the database need to actually go to the disk. 88 00:05:55,520 --> 00:06:02,780 ‫That's circle ugly mechanical drive and start spinning and reads. 89 00:06:03,050 --> 00:06:03,590 ‫What is it? 90 00:06:03,590 --> 00:06:10,100 ‫Read doesn't read four bytes, it doesn't read eight boards and reads the whole God damn block, which 91 00:06:10,100 --> 00:06:13,370 ‫is 512 byte of memory. 92 00:06:13,370 --> 00:06:14,690 ‫And you put it in memory. 93 00:06:15,290 --> 00:06:17,540 ‫And then when we got that, that. 94 00:06:18,690 --> 00:06:25,200 ‫Is slow because that's NATO, but the moment I have all this blook 512, I got a wrong number one. 95 00:06:26,350 --> 00:06:32,860 ‫And I got no number two as well, by for free, I got to number three and four and five and six and 96 00:06:32,860 --> 00:06:38,970 ‫seven until the last straw that is in the book until rule number 128, to be specific. 97 00:06:38,980 --> 00:06:39,280 ‫Right. 98 00:06:39,700 --> 00:06:43,780 ‫What if I want because 128 is the last block that he can fit. 99 00:06:43,780 --> 00:06:44,650 ‫Five hundred and twelve. 100 00:06:45,490 --> 00:06:46,000 ‫That's right. 101 00:06:46,270 --> 00:06:52,030 ‫So now what if I want to roll 129, for example, which happened to be the value? 102 00:06:53,530 --> 00:06:55,710 ‫One of one and a half million light. 103 00:06:57,030 --> 00:07:05,490 ‫If you want that or it's not on the block of the block, it's on the block, that's another IIO and 104 00:07:05,500 --> 00:07:08,730 ‫they the database knows this information is like, oh, another. 105 00:07:08,730 --> 00:07:11,250 ‫I'll go to that location. 106 00:07:11,610 --> 00:07:15,750 ‫That one twenty eight to 129 will say all black. 107 00:07:15,760 --> 00:07:19,100 ‫Number seven now block number eight, it's the next to it. 108 00:07:19,260 --> 00:07:25,650 ‫And then you pull that information back and you might say, are these two blocks nearer to each other. 109 00:07:25,920 --> 00:07:31,670 ‫Could be cabinet based on how fragmented your data is, but usually they are next to each other. 110 00:07:31,830 --> 00:07:35,270 ‫So that's how mechanical drive works in a nutshell. 111 00:07:35,280 --> 00:07:40,920 ‫So how this is how they are stored on desk comes to beautiful. 112 00:07:40,930 --> 00:07:44,010 ‫This is this is this these don't have rotating stuff. 113 00:07:44,010 --> 00:07:45,090 ‫They don't have sectors. 114 00:07:45,210 --> 00:07:48,060 ‫There is no tracks. 115 00:07:48,090 --> 00:07:49,890 ‫There is no all the garbage. 116 00:07:50,310 --> 00:07:50,970 ‫There is. 117 00:07:50,970 --> 00:07:55,140 ‫However, the idea of blocks still and block have a size. 118 00:07:55,360 --> 00:07:55,770 ‫All right. 119 00:07:56,640 --> 00:08:00,030 ‫512, 1024 whatever. 120 00:08:00,030 --> 00:08:00,360 ‫Right. 121 00:08:00,450 --> 00:08:03,540 ‫And this blocks of memory have pages. 122 00:08:04,370 --> 00:08:09,410 ‫And each page has a size, but it's the same thing, right, and instead the database. 123 00:08:10,490 --> 00:08:16,730 ‫Go back to the our representation, logical representation instead of the database storing that track 124 00:08:16,730 --> 00:08:19,760 ‫and sector where the actual stuff is for. 125 00:08:19,760 --> 00:08:23,450 ‫This is the it just stored the block number and the page number. 126 00:08:23,480 --> 00:08:23,800 ‫So. 127 00:08:23,800 --> 00:08:24,260 ‫All right. 128 00:08:24,300 --> 00:08:30,430 ‫Number one is block number 17 and page number eight. 129 00:08:30,950 --> 00:08:31,330 ‫Right. 130 00:08:31,580 --> 00:08:39,470 ‫And just pull that information when it pulled that page, let's say 512 bytes and that page, we have 131 00:08:39,470 --> 00:08:45,850 ‫that beautiful page we got wrong number one and two and three and four and five and six right up until 132 00:08:45,850 --> 00:08:47,600 ‫all 128, same thing. 133 00:08:47,600 --> 00:08:53,810 ‫And we didn't talk about rights per say, but I'm going to mention it in that way after a while. 134 00:08:53,810 --> 00:08:54,950 ‫But yeah. 135 00:08:54,950 --> 00:08:56,030 ‫So that's the same thing. 136 00:08:56,030 --> 00:08:58,550 ‫You go back and you read it exactly the same. 137 00:08:58,560 --> 00:09:05,390 ‫However, it's 100, 200 to 400 times faster because it's a random access. 138 00:09:05,390 --> 00:09:05,830 ‫Right. 139 00:09:05,930 --> 00:09:14,690 ‫And instead of spinning wheel, it's it's literally you tell that I controller of us is the go to that 140 00:09:14,690 --> 00:09:18,110 ‫particular block, that particular page and pull it. 141 00:09:18,110 --> 00:09:23,050 ‫And when you pull a block, you usually pull all the pages with it. 142 00:09:23,060 --> 00:09:26,720 ‫That so that's what happens in an SSD. 143 00:09:26,870 --> 00:09:29,860 ‫When you pull a block, you pull all the pages with it as well. 144 00:09:30,710 --> 00:09:31,370 ‫Let's go through. 145 00:09:31,380 --> 00:09:32,060 ‫All right. 146 00:09:32,630 --> 00:09:35,120 ‫I want to write to. 147 00:09:36,530 --> 00:09:43,280 ‫Paige, we never write to pages, right, as users, we write to Rose is like, oh, I'm going to update 148 00:09:43,280 --> 00:09:48,870 ‫this rule number nine to be four instead of one point five million to be two million. 149 00:09:49,550 --> 00:09:50,900 ‫So what what do we do here? 150 00:09:50,910 --> 00:09:51,680 ‫What does that mean? 151 00:09:52,400 --> 00:09:55,760 ‫That translates first of all, that's rule number nine. 152 00:09:55,940 --> 00:09:57,300 ‫So pull that role. 153 00:09:57,350 --> 00:09:58,220 ‫What does it mean? 154 00:09:58,220 --> 00:09:58,850 ‫Where is wrong? 155 00:09:58,850 --> 00:10:07,160 ‫Number nine or number nine in the database there is metadata says order number is block number 302 and 156 00:10:07,160 --> 00:10:08,570 ‫then pull that. 157 00:10:08,690 --> 00:10:09,530 ‫That's the first thing. 158 00:10:09,800 --> 00:10:11,030 ‫And then I'm going to update it. 159 00:10:11,030 --> 00:10:12,500 ‫And it's one point five million. 160 00:10:13,400 --> 00:10:18,100 ‫Update that for White to say two million updated in memory. 161 00:10:18,350 --> 00:10:20,660 ‫Now I'm going to write it back. 162 00:10:21,020 --> 00:10:22,760 ‫And here's how SSD works. 163 00:10:23,180 --> 00:10:30,480 ‫I'm going to talk about how this is the works and I'm going to talk about how the sector works, the 164 00:10:30,500 --> 00:10:31,460 ‫mechanical drive. 165 00:10:31,700 --> 00:10:39,920 ‫So for the SSD, when you want to write that block, first of all, you write only the pages in the 166 00:10:39,920 --> 00:10:40,720 ‫block, right. 167 00:10:40,880 --> 00:10:48,110 ‫So that change that one point five million existing in a page number one. 168 00:10:48,110 --> 00:10:48,520 ‫Right. 169 00:10:49,220 --> 00:10:51,980 ‫But if you write it, you change it to a two million. 170 00:10:51,990 --> 00:10:54,710 ‫You have to always create a new page. 171 00:10:54,830 --> 00:10:56,050 ‫That's how SSD works. 172 00:10:56,270 --> 00:11:05,560 ‫So you write a new page and then you flush back that block as a different page to describe. 173 00:11:06,140 --> 00:11:11,450 ‫And this information, reading and writing to the same location that block. 174 00:11:11,450 --> 00:11:16,730 ‫And as this idea is extremely Hertz, the SSD feeling. 175 00:11:16,760 --> 00:11:17,120 ‫Right. 176 00:11:17,520 --> 00:11:22,310 ‫This is these have shelf-life and this block, this block writing and reading. 177 00:11:22,310 --> 00:11:26,390 ‫The rewriting, to be specific, has some shelf life. 178 00:11:26,390 --> 00:11:30,620 ‫And this property and SSD is called endurance, literally. 179 00:11:30,620 --> 00:11:37,730 ‫How many times you can write to the same block before that block is dead and at that block is bed. 180 00:11:37,940 --> 00:11:39,250 ‫We cannot reuse it. 181 00:11:39,440 --> 00:11:40,340 ‫That means. 182 00:11:41,430 --> 00:11:50,250 ‫We just lost space in our society can take that with the hard disk drive, which is the physical thing, 183 00:11:51,130 --> 00:11:55,470 ‫you can literally go back and ride to the same location. 184 00:11:55,510 --> 00:11:55,720 ‫Right. 185 00:11:55,890 --> 00:12:02,130 ‫And you can write to it along time because it's just magnetic right idea. 186 00:12:02,140 --> 00:12:06,750 ‫So you can straight right to it without any problem, because when you write to it, you're going to 187 00:12:06,750 --> 00:12:08,060 ‫write an entire block back. 188 00:12:08,070 --> 00:12:09,330 ‫You cannot just write one bytes. 189 00:12:09,660 --> 00:12:11,850 ‫That's that's not how IO controls work. 190 00:12:12,240 --> 00:12:12,600 ‫So. 191 00:12:13,530 --> 00:12:18,630 ‫So when you do that, when you change the last place, you take that whole block and just flush it back 192 00:12:18,630 --> 00:12:24,890 ‫to disk and SSD, there is a limit to how much how much time you can ride to it. 193 00:12:25,080 --> 00:12:30,390 ‫But for the hard disk drive, there is no limit to how many times you can write. 194 00:12:30,390 --> 00:12:31,490 ‫You can write to the same block. 195 00:12:31,510 --> 00:12:33,000 ‫It's OK. 196 00:12:33,210 --> 00:12:38,820 ‫Sometimes sectors get corrupt, but that's rarely happens compared to is is the right. 197 00:12:38,970 --> 00:12:42,300 ‫So SSD faster reading and writing. 198 00:12:43,490 --> 00:12:50,120 ‫But have little short shelf life depends on their endurance, so this is the power, that hard disk 199 00:12:50,120 --> 00:12:50,630 ‫drive. 200 00:12:50,660 --> 00:12:52,850 ‫They are a little bit slower. 201 00:12:52,880 --> 00:12:58,700 ‫They are slow because they are literally abiding by the laws of physics. 202 00:12:58,700 --> 00:12:59,080 ‫Right. 203 00:12:59,550 --> 00:13:01,040 ‫That's not electro magnetic. 204 00:13:01,040 --> 00:13:04,280 ‫It's not magnetic and light and electricity. 205 00:13:04,280 --> 00:13:04,550 ‫Right. 206 00:13:04,550 --> 00:13:11,180 ‫Is just using literally physical stuff to sneak back to a location and then literally. 207 00:13:11,180 --> 00:13:11,600 ‫Right. 208 00:13:11,600 --> 00:13:15,470 ‫All these lights, one zero zero zero one zero zero writes all this information to disk. 209 00:13:15,680 --> 00:13:16,050 ‫Right. 210 00:13:16,670 --> 00:13:26,240 ‫That was a little bit of a brief introduction about how databases store information to disguise how 211 00:13:26,240 --> 00:13:28,280 ‫disk drives are different than SSD. 212 00:13:28,440 --> 00:13:31,940 ‫You really sometimes need to understand how these internal works. 213 00:13:32,120 --> 00:13:42,530 ‫There are papers and people taking CDs just discussing how can we squeeze as much performance from SSD 214 00:13:42,530 --> 00:13:44,000 ‫because those guys are the future. 215 00:13:44,000 --> 00:13:46,070 ‫Obviously, those those guys are not dead. 216 00:13:46,080 --> 00:13:47,720 ‫The mechanical drive we're still using. 217 00:13:47,720 --> 00:13:49,550 ‫But these are the performance stuff. 218 00:13:49,550 --> 00:13:57,860 ‫But we have noticed with use the data structures that we have built BTD, to be specific. 219 00:13:58,190 --> 00:14:02,090 ‫They kill those systems if they are not configured properly. 220 00:14:02,270 --> 00:14:06,710 ‫Because what do Beatriz's do better is when you keep inserting stuff. 221 00:14:07,340 --> 00:14:07,640 ‫Yeah. 222 00:14:07,640 --> 00:14:11,360 ‫And such thing as the love new inserts. 223 00:14:11,540 --> 00:14:16,010 ‫If you're inserting new stuff, that's the best thing you can do, because in search of new stuff, 224 00:14:16,010 --> 00:14:21,020 ‫you're always taking new blocks and you're writing to new blocks. 225 00:14:21,230 --> 00:14:24,140 ‫You're not overriding existing block. 226 00:14:24,140 --> 00:14:28,790 ‫So you're not reading something changing and manipulating and writing to the same block. 227 00:14:29,980 --> 00:14:35,350 ‫These don't like that because you can only change it so much when I say to them so much, I'm talking 228 00:14:35,350 --> 00:14:41,940 ‫about 500, 700, and that's how it increases the cost go up as well. 229 00:14:41,960 --> 00:14:43,900 ‫Ride the endurance of that as deep. 230 00:14:44,140 --> 00:14:44,480 ‫Right. 231 00:14:44,500 --> 00:14:48,040 ‫So Beatriz's when we designed this thing, we didn't we didn't. 232 00:14:48,040 --> 00:14:52,120 ‫We designed a way back in the 60s and 70s. 233 00:14:52,340 --> 00:14:53,620 ‫I wasn't born back then. 234 00:14:53,620 --> 00:14:59,110 ‫But those data structures didn't really think about insurgences. 235 00:14:59,140 --> 00:15:01,360 ‫Update is like, OK, we'll just insert stuff. 236 00:15:01,360 --> 00:15:01,630 ‫Right. 237 00:15:02,500 --> 00:15:10,150 ‫And here's where the problem of misery Belltrees and again, if it's configured incorrectly, if you 238 00:15:10,150 --> 00:15:12,130 ‫keep inserting in your tables. 239 00:15:13,100 --> 00:15:20,540 ‫You have a B3 three index, and that index has to be large first, not just one into primer keys could 240 00:15:20,540 --> 00:15:23,260 ‫be composed of strings and all that stuff. 241 00:15:23,780 --> 00:15:30,760 ‫Then as you insert the B tree, that three will try to grow. 242 00:15:30,770 --> 00:15:31,150 ‫Right. 243 00:15:31,430 --> 00:15:35,240 ‫And when it tries to win, it's about to get imbalanced. 244 00:15:36,560 --> 00:15:41,300 ‫The tree will shuffle itself and rebalance itself, and that's that where it kills. 245 00:15:41,330 --> 00:15:44,870 ‫This is the when you rebalance, what does it mean? 246 00:15:44,900 --> 00:15:47,000 ‫Yes, you are inserting into your logical table. 247 00:15:47,000 --> 00:15:48,400 ‫You're just appending data. 248 00:15:48,710 --> 00:15:52,070 ‫But the index is restructuring itself, right? 249 00:15:52,270 --> 00:15:52,970 ‫Was this. 250 00:15:54,090 --> 00:15:55,470 ‫Or is this right? 251 00:15:55,710 --> 00:16:01,880 ‫So, yeah, so the the index is updating itself, oh, this is no longer the root. 252 00:16:01,890 --> 00:16:03,350 ‫No, this is no, no. 253 00:16:03,390 --> 00:16:06,660 ‫Oh, the child or the child have too many nodes update itself. 254 00:16:06,840 --> 00:16:09,420 ‫So now it's this is the location it's born to do. 255 00:16:09,660 --> 00:16:17,510 ‫So we rebounds and seven rebalancing is nothing but updates when you update in place in SSD. 256 00:16:17,940 --> 00:16:18,870 ‫Oh my God. 257 00:16:19,020 --> 00:16:20,610 ‫That is the worst thing you can do. 258 00:16:20,640 --> 00:16:20,930 ‫Right. 259 00:16:21,030 --> 00:16:23,940 ‫And you do this multiple times and uses these gone. 260 00:16:24,240 --> 00:16:29,370 ‫And when I say elgan, yeah, that block is gone and that block is gone. 261 00:16:29,700 --> 00:16:37,470 ‫Your disk essentially gets smaller because that it can no longer use that block needs to use a new block 262 00:16:37,470 --> 00:16:42,160 ‫in memory and memory and desk and that can slow things down guys. 263 00:16:42,270 --> 00:16:49,440 ‫So that's the idea of SSD, hard disk drive and how database is storing information there. 264 00:16:49,590 --> 00:16:51,510 ‫People still researching this stuff. 265 00:16:51,720 --> 00:16:59,880 ‫So they came up with another data structure, Facebook primarily, I believe they didn't come up with 266 00:16:59,880 --> 00:17:00,780 ‫this data structure. 267 00:17:01,020 --> 00:17:03,150 ‫They said B threes are May. 268 00:17:03,270 --> 00:17:04,380 ‫Well, this is D, right? 269 00:17:04,620 --> 00:17:06,540 ‫So they came up with their own database engine. 270 00:17:06,540 --> 00:17:08,340 ‫They called it Dirac's DB, OK? 271 00:17:08,520 --> 00:17:14,280 ‫And they said we have a lower use case where we're writing stuff all the time. 272 00:17:14,400 --> 00:17:19,690 ‫And those three balancing batteries are killing our asses, these shelf-life and we're throwing this 273 00:17:19,690 --> 00:17:23,550 ‫is d like we don't like there's no tomorrow, so what do we do? 274 00:17:23,760 --> 00:17:32,820 ‫So they used an existing data structure called log structure merge three or l e emem right. 275 00:17:33,480 --> 00:17:38,610 ‫LSM trees are append only they are great for appends. 276 00:17:38,620 --> 00:17:38,910 ‫Right. 277 00:17:38,910 --> 00:17:42,750 ‫So they it's, it's, it works and as levels right. 278 00:17:42,990 --> 00:17:48,120 ‫I'm not going to go into details but that's essentially then it's also a few levels. 279 00:17:48,130 --> 00:17:52,530 ‫It works at a memory level and then level zero, level one, level three and level four. 280 00:17:52,710 --> 00:17:55,380 ‫And these levels are always inserts. 281 00:17:55,380 --> 00:18:02,610 ‫So the index, even if you build an L symmetry index base, then it always just inserts at the end. 282 00:18:02,610 --> 00:18:04,920 ‫And that's really nice for us. 283 00:18:05,130 --> 00:18:10,170 ‫Is this the love that obviously you have to have a larger as D2 if you inserting a lot of information. 284 00:18:10,170 --> 00:18:17,640 ‫But guys, that was a but a long video talking about how database is store information into to the desk. 285 00:18:17,640 --> 00:18:18,060 ‫Right. 286 00:18:18,720 --> 00:18:24,710 ‫I like to talk without graphics and stuff like that because I might use this as a podcast and check 287 00:18:24,720 --> 00:18:25,350 ‫my podcast. 288 00:18:25,350 --> 00:18:30,330 ‫Guys, if you're interested, if you want to listen to this while you're in a train or background or 289 00:18:30,330 --> 00:18:35,460 ‫you're working out, you can listen to this information without actually looking at and expecting something 290 00:18:36,450 --> 00:18:37,800 ‫graphical on the videos. 291 00:18:37,800 --> 00:18:44,940 ‫I do make other videos where I use a virtual board, but sometimes I make this more casual, chatty 292 00:18:45,300 --> 00:18:46,820 ‫kind of videos as well. 293 00:18:46,950 --> 00:18:49,280 ‫Alright, guys like this video is like it. 294 00:18:49,470 --> 00:18:50,100 ‫This like it. 295 00:18:50,100 --> 00:18:53,310 ‫If you don't like it, I'm going to see you on the next one. 296 00:18:53,310 --> 00:18:55,350 ‫You guys stay awesome.