1 00:00:00,120 --> 00:00:06,000 ‫All right, guys, so now that we have a million rows, what are we going to do is insert a new file 2 00:00:06,000 --> 00:00:09,420 ‫here and then I'm going to call it server cursor. 3 00:00:10,720 --> 00:00:18,200 ‫Server side, curser, the pie, and then I'm going to create another file called Client Server, so 4 00:00:18,200 --> 00:00:19,320 ‫I started with the client. 5 00:00:19,540 --> 00:00:28,300 ‫How do we do a client curser that actually what are we going to do is query all the rows and then just 6 00:00:28,300 --> 00:00:33,370 ‫measure the time for the query to get executed. 7 00:00:33,370 --> 00:00:35,990 ‫Then we're going to fetch the first 50 rows. 8 00:00:36,060 --> 00:00:38,500 ‫OK, so that's that's what that's our criteria. 9 00:00:38,500 --> 00:00:43,390 ‫And we're going to do it first with their client cursor and then we're going to do it with the server 10 00:00:43,390 --> 00:00:48,880 ‫cursor again and budget cycle and then connection equal. 11 00:00:48,920 --> 00:00:50,030 ‫Well, let's deal. 12 00:00:50,200 --> 00:00:50,770 ‫Right, guys. 13 00:00:50,780 --> 00:00:52,770 ‫Just saving some time here, OK? 14 00:00:53,540 --> 00:00:54,520 ‫I have a connection. 15 00:00:54,550 --> 00:00:55,950 ‫Connection with close. 16 00:00:56,890 --> 00:01:00,360 ‫OK, let's do a cursor that is client Cycloset. 17 00:01:00,640 --> 00:01:03,670 ‫So of course our core connection to the cursor. 18 00:01:03,790 --> 00:01:12,940 ‫If you don't specify any parameter here, you get a client side cursor, client side cursor and we explain 19 00:01:12,940 --> 00:01:13,180 ‫the one. 20 00:01:13,180 --> 00:01:13,800 ‫Is that right? 21 00:01:14,110 --> 00:01:21,520 ‫And then when we want to do as cursor dot execute, select all from employees, obviously this is a 22 00:01:21,520 --> 00:01:23,890 ‫huge bad mistake to do that. 23 00:01:23,890 --> 00:01:24,140 ‫Right. 24 00:01:24,160 --> 00:01:26,650 ‫But we're doing some performance thing anyway, right. 25 00:01:26,860 --> 00:01:31,620 ‫So even with a workload, sometimes it gets quick and gets slow. 26 00:01:31,640 --> 00:01:31,970 ‫Right. 27 00:01:32,530 --> 00:01:35,170 ‫But that essentially will execute everything. 28 00:01:35,380 --> 00:01:36,240 ‫And then what? 29 00:01:36,250 --> 00:01:39,750 ‫We will return or return a bunch of arrows for us? 30 00:01:40,430 --> 00:01:43,570 ‫No, that will not return any rules, actually. 31 00:01:43,750 --> 00:01:50,950 ‫Again, so Curser does fetch many will actually return the number of rows. 32 00:01:50,950 --> 00:01:53,310 ‫And I want just 50 euros, OK? 33 00:01:53,920 --> 00:01:55,990 ‫And I'm not going to print them or anything. 34 00:01:56,020 --> 00:02:00,900 ‫OK, so now we need to actually measure the time to do that, OK? 35 00:02:00,910 --> 00:02:03,530 ‫And to do that, we're going to need Fordism Library time. 36 00:02:04,050 --> 00:02:04,530 ‫All right. 37 00:02:05,230 --> 00:02:11,590 ‫I just like use a TI so we can do it simply and then let's do that starts time. 38 00:02:11,900 --> 00:02:13,660 ‫OK, equal t the time. 39 00:02:14,830 --> 00:02:23,230 ‫Make a snapshot before we start the cursor and after we start the cursor we will get the time divided 40 00:02:23,740 --> 00:02:25,510 ‫subtracted from the start time. 41 00:02:25,700 --> 00:02:26,100 ‫Right. 42 00:02:26,410 --> 00:02:28,690 ‫And that will be in seconds essentially. 43 00:02:28,900 --> 00:02:29,240 ‫Right. 44 00:02:29,260 --> 00:02:30,720 ‫So I want it in milliseconds. 45 00:02:30,720 --> 00:02:32,890 ‫So I'm that's multiplied by a thousand again. 46 00:02:33,640 --> 00:02:33,970 ‫All right. 47 00:02:33,970 --> 00:02:47,920 ‫So now we have and we're going to print F cursor established in e millisecond cool. 48 00:02:49,240 --> 00:02:53,050 ‫And then we're going to do the same exact thing for the execute. 49 00:02:56,320 --> 00:03:02,380 ‫Cool, and then we're going to do but this is different now because I established on the established 50 00:03:02,950 --> 00:03:11,380 ‫query all rows, I would say this Caldas executes the query. 51 00:03:12,070 --> 00:03:12,470 ‫All right. 52 00:03:12,970 --> 00:03:15,510 ‫And then this is different. 53 00:03:15,520 --> 00:03:17,470 ‫This is actually pitching this thing. 54 00:03:17,530 --> 00:03:20,680 ‫OK, and we're going to explain how is this different? 55 00:03:20,700 --> 00:03:22,270 ‫OK, execute the query. 56 00:03:22,270 --> 00:03:25,330 ‫And this is actually fetching 50 arrows. 57 00:03:25,480 --> 00:03:30,340 ‫First, if you just fetch the first draw and tell me how long it takes. 58 00:03:30,370 --> 00:03:34,450 ‫OK, how about we run and see how this is going on? 59 00:03:35,110 --> 00:03:38,130 ‫Oh, I forgot to cross the cursor guys because of the clues. 60 00:03:38,680 --> 00:03:39,170 ‫OK. 61 00:03:40,890 --> 00:03:42,100 ‫And then a start. 62 00:03:45,960 --> 00:03:49,950 ‫All right, so let's zoom in here so you guys can read this. 63 00:03:52,350 --> 00:03:57,970 ‫Establishing the cursor obviously doesn't take anything is just literally declaring that statement right 64 00:03:58,050 --> 00:04:05,820 ‫or point zero to millisecond, but look at executing the query, which is we didn't have to actually 65 00:04:05,820 --> 00:04:10,050 ‫get the result was just executing the query for every single thing. 66 00:04:10,050 --> 00:04:17,850 ‫And do the cursor took eight hundred forty five milliseconds and then fetching the first first if there 67 00:04:17,850 --> 00:04:18,630 ‫was nothing. 68 00:04:18,960 --> 00:04:22,950 ‫Right, almost nothing because we have everything in the client. 69 00:04:22,950 --> 00:04:23,280 ‫Right. 70 00:04:23,700 --> 00:04:30,630 ‫We now if I look at the processes like the processes you just taking containing one million tuple row, 71 00:04:30,660 --> 00:04:36,630 ‫OK, and obviously the more you execute it's a tuple, so it's not an array. 72 00:04:36,640 --> 00:04:39,330 ‫So we didn't actually allocate everything. 73 00:04:39,960 --> 00:04:40,990 ‫So it's slightly different. 74 00:04:40,990 --> 00:04:41,820 ‫It's a read-only.