![](/img/trans.png)
[英]Do I need to add an index on a mySQL table if the ID column is the primary key?
[英]Do we need to add primary key to multiple columns index?
我們是否需要向多個列索引添加主鍵? 還是會自動放在那里?
ALTER TABLE `wp_posts`
ADD PRIMARY KEY (`ID`),
ADD KEY `post_name` (`post_name`(191)),
ADD KEY `type_status_date` (`post_type`,`post_status`,`post_date`,`ID`),
ADD KEY `post_parent` (`post_parent`),
ADD KEY `post_author` (`post_author`);
我得出一個結論,他們將ID放在其中,因為使用“ ORDER BY ID”會更快,因為引擎不需要排序而是遵循索引 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.