0% found this document useful (0 votes)
23 views

MySQL Indexes

MySQL indexes function like book indexes to improve search speed by storing column data in a distinct place. Indexes are created with CREATE INDEX and applied to one or multiple columns to optimize searches on large datasets.

Uploaded by

us22mac2r30
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

MySQL Indexes

MySQL indexes function like book indexes to improve search speed by storing column data in a distinct place. Indexes are created with CREATE INDEX and applied to one or multiple columns to optimize searches on large datasets.

Uploaded by

us22mac2r30
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

MySQL Indexes

MySQL Indexes
MySQL Indexes
MySQL Indexes
the index of a table functions like the index of a book
MySQL Indexes
the index of a table functions like the index of a book
- data is taken from a column of the table and is stored in a certain
order in a distinct place, called an index
MySQL Indexes
the index of a table functions like the index of a book
- data is taken from a column of the table and is stored in a certain
order in a distinct place, called an index

your datasets will typically contain 100,000+ or even 1,000,000+ records


MySQL Indexes
the index of a table functions like the index of a book
- data is taken from a column of the table and is stored in a certain
order in a distinct place, called an index

your datasets will typically contain 100,000+ or even 1,000,000+ records

- the larger a database is, the slower the process of finding the record
or records you need
MySQL Indexes
we can use an index that will increase the speed of searches related to
a table
MySQL Indexes
we can use an index that will increase the speed of searches related to
a table

CREATE INDEX index_name


ON table_name (column_1, column_2, …);
MySQL Indexes
we can use an index that will increase the speed of searches related to
a table

CREATE INDEX index_name


ON table_name (column_1, column_2, …);

the parentheses serve us to indicate the column


names on which our search will be based
MySQL Indexes
we can use an index that will increase the speed of searches related to
a table

CREATE INDEX index_name


ON table_name (column_1, column_2, …);

these must be fields from your data table you


will search frequently
MySQL Indexes
composite indexes
MySQL Indexes
composite indexes
- applied to multiple columns, not just a single one
MySQL Indexes
composite indexes
- applied to multiple columns, not just a single one

CREATE INDEX index_name


ON table_name (column_1, column_2, …);
MySQL Indexes
composite indexes
- applied to multiple columns, not just a single one

CREATE INDEX index_name


ON table_name (column_1, column_2, …);

- carefully pick the columns that would optimize your search!


MySQL Indexes
primary and unique keys are MySQL indexes
MySQL Indexes
primary and unique keys are MySQL indexes
- they represent columns on which a person would typically base their
search
MySQL Indexes
MySQL Indexes
SQL specialists are always aiming for a good balance between the
improvement of speed search and the resources used for its execution
MySQL Indexes
SQL specialists are always aiming for a good balance between the
improvement of speed search and the resources used for its execution

the costs of having an index might


small datasets be higher than the benefits
MySQL Indexes
SQL specialists are always aiming for a good balance between the
improvement of speed search and the resources used for its execution

the costs of having an index might


small datasets be higher than the benefits

a well-optimized index can make a


large datasets positive impact on the search
process

You might also like