在MySQL中强制对联接使用索引的语法是什么 [英] What is the syntax to force the use of an index for a join in MySQL
本文介绍了在MySQL中强制对联接使用索引的语法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在进行直接选择时使用"FORCE/USE/IGNORE INDEX"的文档已被详细记录,但是从文档中尚不清楚如何为JOIN进行操作.
The use of the "FORCE/USE/IGNORE INDEX" when doing a straightforward select is well-documented, but it's not clear from the documentation how to do it for a JOIN.
如何强制将特定索引用于联接表?
How do you force a specific index to be used for a joined table?
推荐答案
FORCE/USE/IGNORE放在您要加入的表名之后,如果使用的是别名,则在别名之后.
The FORCE/USE/IGNORE goes after the table name you are joining, and after the alias if you're using one.
SELECT
t1.`id` AS `id_1`,
t2.`id` AS `id_2`
FROM
`table1` t1
LEFT OUTER JOIN
`table2` t2
FORCE INDEX FOR JOIN (`table1_id`)
ON (t2.`table1_id` = t1.`id`)
这篇关于在MySQL中强制对联接使用索引的语法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文