【问题】 当select 中存在关联子查询时,如何进行优化。 看说明文档中有引入apply。但具体怎么修改SQL?
语句例如
select
case when 1
then (select value from table b where a.col=b.col limit 1)
else
then (select value from table c where a.col=c.col limit 1)
end
from table a
TiDB 对关联子查询会自动使用 apply 算子,但是不支持这种语法。
我看你贴的 SQL 不是 MySQL 语法,MySQL 语法的话大概是这样: select case when 1 then (select value from b where a.col=b.col limit 1) else (select value from c where a.col=c.col limit 1) end from a;
先看看是不是想要的效果呢?