1 00:00:01,280 --> 00:00:06,920 ‫Demo, let's jump into this guy, so what we do here, guys, we're going to use Docker going to spin 2 00:00:06,920 --> 00:00:12,830 ‫up a beautiful Postgres instance, and then we're going to insert around 10 million rolls in that table 3 00:00:12,950 --> 00:00:17,720 ‫and then we'll get around, create table partitions, and then we're going to join the partitions to 4 00:00:17,720 --> 00:00:21,980 ‫the master table and then do some fancy kuris explaining all that jazz. 5 00:00:22,220 --> 00:00:22,590 ‫Right. 6 00:00:22,640 --> 00:00:24,210 ‫How about we jump into it, guys? 7 00:00:24,500 --> 00:00:28,190 ‫All right, guys, let's just jump into the demo, guys. 8 00:00:28,190 --> 00:00:34,910 ‫So requirement here just have Docker and that's it, because I'm going to open up a post Chris Aniston's 9 00:00:34,910 --> 00:00:38,900 ‫because I play with this is way, way easier than installing Puskás on my own machine. 10 00:00:38,900 --> 00:00:40,440 ‫But if you have it, never mind. 11 00:00:40,850 --> 00:00:46,430 ‫So once you have that, I'm going to actually run a Docker command here. 12 00:00:46,640 --> 00:00:46,870 ‫Right. 13 00:00:47,030 --> 00:00:52,940 ‫And I don't need to expose the ports for possible because I'm going to bash into the container inside 14 00:00:52,940 --> 00:00:56,630 ‫Postgres and I'm going to run the sequel commands Inside Bosco's container. 15 00:00:56,900 --> 00:00:58,250 ‫So I'm going to do a docker one. 16 00:00:58,970 --> 00:01:05,810 ‫And then all I have to do is like basically do that name, give it a name, let's call it a PG mean 17 00:01:06,110 --> 00:01:06,710 ‫whatever. 18 00:01:07,150 --> 00:01:07,510 ‫Right. 19 00:01:08,030 --> 00:01:09,250 ‫That's the name of the container. 20 00:01:09,530 --> 00:01:16,700 ‫And then once I'd have that, I want to detach this container because I want to use the same terminal. 21 00:01:17,030 --> 00:01:18,260 ‫And then finally. 22 00:01:19,650 --> 00:01:25,830 ‫Do an environment variable postscripts, password that's in acquirement, recent one, I just give it 23 00:01:25,830 --> 00:01:27,670 ‫a prosperous password, any any password. 24 00:01:27,780 --> 00:01:29,270 ‫And then finally, just do Postgres. 25 00:01:29,460 --> 00:01:30,830 ‫This is the image you're going to pull from. 26 00:01:30,840 --> 00:01:34,170 ‫And then just like that, we spun up a Puskás. 27 00:01:34,170 --> 00:01:37,020 ‫In a sense, if I do this, we can have that. 28 00:01:37,020 --> 00:01:40,000 ‫We have a podcast and it's a running and this is my name. 29 00:01:40,350 --> 00:01:46,660 ‫So now we're going to do it as Goldacre execute interactive terminal. 30 00:01:46,710 --> 00:01:49,620 ‫I want to jump into PJI main inside it. 31 00:01:49,800 --> 00:01:50,130 ‫Right. 32 00:01:50,140 --> 00:01:51,450 ‫I want to run the command. 33 00:01:51,780 --> 00:01:53,280 ‫Basche Right. 34 00:01:53,850 --> 00:01:55,810 ‫And the ones we bash into the container. 35 00:01:55,830 --> 00:02:00,480 ‫I want to do a sequel, DCU, which is the username and Postgres. 36 00:02:00,510 --> 00:02:05,600 ‫I'm just like that since I am the owner of this is going to let me in immediately. 37 00:02:05,610 --> 00:02:09,530 ‫So now I'm in, I'm in the beautiful Postgres CAMAC. 38 00:02:09,580 --> 00:02:09,780 ‫Right. 39 00:02:09,810 --> 00:02:11,940 ‫I can do stuff right. 40 00:02:12,660 --> 00:02:13,040 ‫All right. 41 00:02:13,860 --> 00:02:14,570 ‫So it going to do. 42 00:02:14,580 --> 00:02:16,110 ‫I'm going to create a table guys. 43 00:02:16,800 --> 00:02:19,110 ‫I'm going to call this great table grades. 44 00:02:19,320 --> 00:02:24,720 ‫This is just a bunch of student grades and I'm going to I'm not going to maintain names of the students 45 00:02:24,720 --> 00:02:25,160 ‫or anything. 46 00:02:25,170 --> 00:02:29,640 ‫This is just a garbage table where we have literally an ID I sequence. 47 00:02:29,640 --> 00:02:34,050 ‫I did just one, two, three, four, five, six and a grade. 48 00:02:34,260 --> 00:02:34,860 ‫That's it. 49 00:02:35,040 --> 00:02:35,370 ‫Right. 50 00:02:35,610 --> 00:02:36,300 ‫Nothing else. 51 00:02:36,780 --> 00:02:39,480 ‫So I'm going to grade I'm going to call it grades original. 52 00:02:40,350 --> 00:02:40,800 ‫Right. 53 00:02:40,800 --> 00:02:44,340 ‫And then I am going to get given an ID cyrille. 54 00:02:44,340 --> 00:02:48,630 ‫That means every role I insert will automatically get a sequence and increment. 55 00:02:49,030 --> 00:02:49,650 ‫I'm going to make it. 56 00:02:49,650 --> 00:02:50,070 ‫No, no. 57 00:02:50,100 --> 00:02:52,470 ‫This is a requirement for partitioning. 58 00:02:52,470 --> 00:02:53,450 ‫Everything should be not null. 59 00:02:53,760 --> 00:02:54,070 ‫Right. 60 00:02:54,900 --> 00:02:57,510 ‫Everything that your partition against should be not know. 61 00:02:57,870 --> 00:03:02,850 ‫And then I'm going to do a G, which is the grade itself G and that's also an integer. 62 00:03:02,860 --> 00:03:03,450 ‫No, no. 63 00:03:03,930 --> 00:03:07,030 ‫And just like that already. 64 00:03:07,830 --> 00:03:14,160 ‫So now I'm going to insert around 10 million rows in this table and that's extremely easy to do. 65 00:03:14,310 --> 00:03:17,970 ‫So all we have to do is insert into grades original. 66 00:03:18,120 --> 00:03:23,400 ‫I'm going to insert before I add an index to the G just because it's faster this way. 67 00:03:23,400 --> 00:03:23,660 ‫Right. 68 00:03:23,670 --> 00:03:28,380 ‫Because I don't have to maintain the index while I'm inserting this stuff. 69 00:03:28,590 --> 00:03:32,970 ‫So I'm going to answer this select star I select. 70 00:03:33,300 --> 00:03:34,010 ‫Here's what I'm gonna do. 71 00:03:34,020 --> 00:03:40,560 ‫I'm going to floor a random function, which are the random function gives me fractions like point zero 72 00:03:40,560 --> 00:03:43,560 ‫nine point point zero two point zero nine. 73 00:03:43,560 --> 00:03:44,520 ‫That's the maximum number. 74 00:03:44,760 --> 00:03:46,770 ‫So I'm going to multiply the random by hundred. 75 00:03:47,040 --> 00:03:50,310 ‫That gives me values from zero to ninety nine. 76 00:03:50,340 --> 00:03:55,850 ‫And that's exactly the grades right out of hundred, essentially not quite a hundred. 77 00:03:56,700 --> 00:03:58,710 ‫I'm not going to get one hundred but who cares. 78 00:03:58,710 --> 00:03:58,960 ‫Right. 79 00:03:59,280 --> 00:04:03,480 ‫So then then I'm going to floor the whole thing because I'm going to get the fraction, the floor will 80 00:04:03,480 --> 00:04:04,150 ‫give me the function. 81 00:04:04,440 --> 00:04:08,130 ‫So now I'm selecting this from generate series. 82 00:04:08,880 --> 00:04:13,920 ‫This is a function that you basically will every time you call you, you specify how many times you 83 00:04:13,920 --> 00:04:14,430 ‫want to call it. 84 00:04:14,610 --> 00:04:16,680 ‫I don't want to call it ten million times. 85 00:04:17,760 --> 00:04:21,630 ‫And I just added this coming so I can see for myself so that I actually like that. 86 00:04:21,900 --> 00:04:24,270 ‫And then let's just insert and I says, wait. 87 00:04:24,420 --> 00:04:26,020 ‫Oh, bad, bad, bad, bad. 88 00:04:26,040 --> 00:04:33,480 ‫OK, so what I'm going to do, I forgot to specify the column so insert into so I have to do G I guess 89 00:04:33,480 --> 00:04:35,040 ‫I didn't specify the feel itself. 90 00:04:35,850 --> 00:04:36,510 ‫That's my bad. 91 00:04:37,230 --> 00:04:39,270 ‫So all happened here is the idea. 92 00:04:39,270 --> 00:04:44,850 ‫You don't have to specify because it's, it's, it will be auto generated but the g you have to specify 93 00:04:44,850 --> 00:04:47,460 ‫it and the value will go to the G these two values. 94 00:04:47,610 --> 00:04:50,430 ‫And just like that we have ten million rows. 95 00:04:50,640 --> 00:04:52,230 ‫Obviously we can, we can generate more. 96 00:04:52,230 --> 00:04:54,890 ‫But just this is just for example, very nice. 97 00:04:55,320 --> 00:05:03,690 ‫So now let's create an index on that create index, let's call it grades, original index on grades, 98 00:05:04,140 --> 00:05:06,720 ‫what we call grades original Orge. 99 00:05:08,440 --> 00:05:13,720 ‫OMG, I said this will create an index so that create a beautiful index and we talked about indexing 100 00:05:14,170 --> 00:05:15,580 ‫and that's it, we have an index. 101 00:05:15,590 --> 00:05:17,970 ‫So let's describe the table we have here. 102 00:05:18,880 --> 00:05:20,200 ‫Boom, just like that. 103 00:05:20,200 --> 00:05:20,880 ‫We have an idea. 104 00:05:20,890 --> 00:05:21,250 ‫We have a.