gpt4 book ai didi

mysql - 通过首先将相关行选择到别名表中来更快地加入?

转载 作者:行者123 更新时间:2023-11-29 07:02:26 25 4
gpt4 key购买 nike

我在 SO 上读到 joinwhere 之前执行,所以我想知道像这样执行连接是否(总是)是个好主意:

SELECT * FROM 
(SELECT * FROM tbl_1 WHERE field = 'the_value') t
JOIN tbl_2 USING (joinable_field)

而不是通常的

SELECT * FROM tbl_1 t1 JOIN tbl_2 t2 USING (joinable_field)
WHERE t1.field = 'the_value'

最佳答案

这样,您就可以限制执行和评估顺序。 t 必须首先创建(可能是“即时”,可能物理上在磁盘上),并且加入 tbl_2

但是,在您的具体情况下,这应该不会有什么坏处。但我也看不到任何好处。

关于mysql - 通过首先将相关行选择到别名表中来更快地加入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9411314/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com