What is the '_idx' suffix for on KEY for MySQL?

南笙酒味 提交于 2019-12-25 02:11:59

问题


Tried searching for this but couldn't find anything that helped me understand.

In CodeIgniter's Session table creation query for example, there's a line:

KEY `last_activity_idx` (`last_activity`)

that comes after defining the column 'last_activity'.

What's this for?


回答1:


That means the column last_activity is indexed, and the name of the index is last_activity_idx. An index means that running conditional queries based on that field will be faster.

For example, if you run a query like:

SELECT * FROM `session_table` WHERE `last_activity` = 1000

If the column is not indexed, MySQL will have to search through every row to check the value of that column. If that column is indexed, MySQL is able to more quickly find rows which match that column.

https://dev.mysql.com/doc/refman/5.5/en/optimization-indexes.html



来源:https://stackoverflow.com/questions/22314046/what-is-the-idx-suffix-for-on-key-for-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!