简体   繁体   中英

Using EXPLAIN or INDEX in MySQL

This is the question I have been given:

Classic Cars frequently run queries using the CUSTOMER table to search for customers based on their postal code. Provide commands that enable modification of this attribute to enhance and optimise the search and retrieval of records which is based on the postal code attribute.

Would I use an EXPLAIN statement or INDEX?

Thanks for your help :)

Would I use an EXPLAIN statement or INDEX?

EXPLAIN is used to obtain a query execution plan (that is, an explanation of how MySQL would execute a query)
INDEX is used to find rows with specific column values quickly. Without an index, MySQL must begin with the first row and then read through the entire table to find the relevant rows.
Now from this pull your own conclusion!


If your search is using as it's predicate the column postal code then and index should be created on this column in order to improve performance. Other wise with no index for it to use a full table scan will be used.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM