How to make JOIN query use index?

前端 未结 6 1787
无人共我
无人共我 2021-02-07 04:49

I have two tables:

CREATE TABLE `articles` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(1000) DEFAULT NULL,
  `last_updated` datetime DEFAULT NULL         


        
6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-07 05:31

    You can use influence MySQL to use KEYS or INDEXES

    For

    • Ordering, or
    • Grouping, or
    • Join

    For extra information, follow this link. I intended to use this for joining (i.e. USE INDEX FOR JOIN (My_Index) but it didn't work as expected. Removing the FOR JOIN part sped up my query significantly, from more than 3.5 hours, to 1-2 seconds. Simply because MySQL was forced to use the right index.

提交回复
热议问题