![]() To add an index to a table, type the following SQL command. At the Enter Password prompt, type your password.At the command prompt, type the following command, replacing username with your A2 Hosting account username, and database with the name of the database:.(You can specify it with InnoDB as well, but it is just ignored. (This means the table has 17 rows where the last name begins with “T”.) Lastly, the Extra value also indicates that MySQL will use an index for the query.Īdding, removing, and viewing indexes in a tableĪfter you analyze your database queries and determine where the performance bottlenecks are, you are ready to add indexes. With MyISAM, you have the option of specifying different levels of checking. Additionally, MySQL will read only 17 rows to generate the result set, instead of all 142 rows. On the other hand, if we were to create an index called index_name for the lastname column, MySQL might generate the following output for the same query: mysql> EXPLAIN SELECT title FROM employees WHERE lastname LIKE 'T%' \GĪs you can see, the possible_keys and key values indicate that MySQL has found an index it can use to optimize the query. This could take quite some time for a large table. If there are 142 total rows in the table, this means MySQL must examine every row to generate the result set. The rows value indicates that MySQL will read 142 rows for this query. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |