WEBVTT

00:07.700 --> 00:10.130
I will call you back again tonight after the lecture in Moscow.

00:10.130 --> 00:11.450
And in this video lecture.

00:11.450 --> 00:15.320
Let's go ahead and look at index and MySQL.

00:15.320 --> 00:21.320
So index is known as a B-tree data structure.

00:21.320 --> 00:27.800
And it is used to find values within a specific column easily and fast because MySQL actually searches

00:27.800 --> 00:30.050
the data sequentially through a column.

00:30.050 --> 00:35.660
So this is going to be a quick lecture because we don't have a very large list.

00:35.660 --> 00:41.000
So this is just a few of our just like seven rows under here.

00:41.000 --> 00:42.140
So it's going to be a quick one.

00:42.140 --> 00:46.070
But it's very important if you are dealing with a very large set of data.

00:46.070 --> 00:51.740
So imagine you have like millions of these employees and we have just several right here.

00:51.770 --> 00:54.080
So that is why you're not going to take much time.

00:54.080 --> 00:58.040
So that's why I don't show the current index of our table.

00:58.040 --> 01:03.920
So to show the current index of this table we go ahead and say show index six.

01:04.580 --> 01:10.970
So should index six from then employees.

01:11.630 --> 01:13.880
So place semicolon and go ahead and run this race.

01:13.880 --> 01:14.600
Check it out.

01:14.600 --> 01:18.260
And now we can see we have this uh index curl.

01:18.260 --> 01:23.900
And now you can see it is a B3 or B3 and all new colors and is visible.

01:23.900 --> 01:25.130
And now.

01:27.230 --> 01:30.410
That is the supervisor of the index is home.

01:30.410 --> 01:32.000
And the first name is key.

01:32.270 --> 01:34.160
You can see the key name is first name.

01:34.160 --> 01:35.750
And the column name is first name.

01:35.750 --> 01:39.650
The coalition is a and the cardinality is six.

01:39.950 --> 01:43.850
Oh and now let's go ahead and create index for this first name.

01:43.850 --> 01:44.750
That is it.

01:44.780 --> 01:47.000
Right in here you can actually create index.

01:47.000 --> 01:50.780
And if you help us to actually speed up the search of our database.

01:50.780 --> 01:55.640
But one thing is that the database we have is just a smaller database.

01:55.640 --> 02:01.340
So the search might not be that visible to you because it's just seven rows.

02:01.340 --> 02:04.580
But if you have millions of it, it's going to make more sense to us.

02:04.580 --> 02:06.650
So that's why I said it's going to be a quick lecture.

02:06.680 --> 02:09.620
Now let's go ahead and create index for the first name.

02:09.620 --> 02:14.420
So go ahead and remove this and I'll go ahead and say create index.

02:15.050 --> 02:17.360
And uh for the first name.

02:17.360 --> 02:20.720
So first underscore name.

02:20.720 --> 02:23.180
So that is going to be the name of the index.

02:23.180 --> 02:27.920
So we just created the first underscore index on employee.

02:28.460 --> 02:34.520
So employees and the index want to create this for the column this column called first name.

02:34.520 --> 02:42.830
So go ahead and insert that first underscore name and go ahead and put a semicolon at the end of this.

02:42.860 --> 02:44.270
Go ahead and execute this query.

02:44.270 --> 02:47.210
And you can see that our index is created.

02:47.210 --> 02:50.720
So now let's go ahead and show this index that we just created.

02:50.720 --> 02:58.190
So I'll go ahead and say show index six show index six.

02:58.190 --> 03:05.330
So from the employees table so employees for a semicolon at end.

03:05.360 --> 03:05.990
And let's go ahead.

03:05.990 --> 03:13.250
And as a kid that so you can see we have our employees one and the index that we just created which

03:13.280 --> 03:16.160
is first underscore name underscore ADX.

03:16.160 --> 03:18.530
And I can see it sequentially.

03:18.530 --> 03:22.520
And uh that is it right here.

03:23.000 --> 03:28.280
Now if you go ahead and uh check out we want to search your table.

03:28.310 --> 03:32.630
So let's go ahead and say you want to search the employee table by the first name, which you have us

03:32.630 --> 03:40.760
to speed our search for a name under employee, maybe Peter, Mark, global, Steve, Michael or anyone.

03:40.790 --> 03:47.720
You go ahead and say select uh, all from the employee.

03:47.840 --> 03:50.540
And then we go ahead and we are close.

03:50.540 --> 03:57.380
So we are the first underscore name is equal to.

03:57.410 --> 03:59.180
Let me go ahead and say press semicolon.

03:59.180 --> 04:02.510
So you can go ahead and insert in maybe George anyone.

04:02.540 --> 04:05.510
So let me say George and go ahead and check it out.

04:05.510 --> 04:07.670
And uh, this is George.

04:08.780 --> 04:11.150
Now you might not make sense to us.

04:11.150 --> 04:16.520
That is why I said that, uh, this is a smaller table, and the search is very fast because we're not

04:16.550 --> 04:21.020
dealing with a large set of data, but we are dealing with a large set of data like millions of that.

04:21.020 --> 04:27.230
And imagine companies that have like six millions, uh, maybe students and so on.

04:27.230 --> 04:30.320
And you are trying to create the database.

04:30.320 --> 04:33.590
The index will actually help you to do it, to be fast.

04:33.620 --> 04:34.100
All right.

04:34.130 --> 04:39.380
But because you have a smaller database which you are using in this lecture, the search is always fast

04:39.380 --> 04:42.110
and you might not actually see the results.

04:42.110 --> 04:43.340
So this is about indexing.

04:43.520 --> 04:47.660
We're not going to talk much on that because I dealt with like a small data set here.

04:47.660 --> 04:50.810
But you can go deep into that and check more about it.

04:50.810 --> 04:53.330
So for now we're going to stop at index.

04:53.330 --> 04:58.760
And uh you go ahead and look more into that with large data set and see what it gives you.

04:58.790 --> 05:00.920
So at the end that is it for now.

05:00.920 --> 05:02.000
So go ahead and check it out.

05:02.180 --> 05:02.720
Done with it.

05:02.720 --> 05:05.270
And if you have any questions please use the question and answer section.

05:05.270 --> 05:07.400
And I'm going to get back to you as soon as possible.

05:07.430 --> 05:08.240
Thank you so much.

05:08.240 --> 05:11.240
And I'm going to see you in the next video lecture.
