这是我收到的问题:
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.
我会使用 EXPLAIN 语句还是 INDEX 吗?
感谢您的帮助:)
最佳答案
我会使用 EXPLAIN 语句还是 INDEX 吗?
EXPLAIN用于获取查询执行计划(即MySQL如何执行查询的解释)
INDEX 用于快速查找具有特定列值的行。如果没有索引,MySQL 必须从第一行开始,然后读取整个表以查找相关行。
现在由此得出你自己的结论!
如果您的搜索使用邮政编码
列作为谓词,则应在此列上创建索引以提高性能。否则,如果没有索引,将使用全表扫描。
关于mysql - 在 MySQL 中使用 EXPLAIN 或 INDEX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22764418/