我被给了这个查询来更新报告,并且在我的计算机上运行需要很长时间。什么是MySQL中的“point-in-select”?
select
c.category_type, t.categoryid, t.date, t.clicks
from transactions t
join category c
on c.category_id = t.categoryid
我问DBA是否有与查询的任何问题,而DBA优化以这种方式查询:
select
(select category_type
from category c where c.category_id = t.categoryid) category_type,
categoryid,
date, clicks
from transactions t
他所描述的第一子查询的“点式选”。我从来没有听说过这个。有人可以解释这个概念吗?
而且第二个查询有更好的表现吗?我认为他们应该非常相似。此外,我从来没有听说过“点选”,Google也没有提到任何事情。 –
你有提供两种'EXPLAIN'的机会吗?第二个查询实际上看起来更糟。 – zerkms
这是[相关子查询](https://en.wikipedia.org/wiki/Correlated_subquery)。请注意,他的短语没有出现在维基链接中,我从来没有听说过它。令我惊讶的是,这使您在RDBMS的现代版本上显着提高了性能。 –