场景:mybatis中一段sql是分页查询,查询中有个查询条件是in一个传入的list,极端情况下这个list会变得很大,导致sql报错。应该怎么解决?
考虑过建临时表,但是还没查询到在select语句里面创建临时表的例子
mybatis动态创建临时表
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答
- engchina 2016-12-27 01:21关注
参考URL:http://blog.csdn.net/engchina/article/details/48250829
使用with,试试下面这个2个方法可不可以。(exists性能比in性能好,请根据需要选择)
1,用in的写法
with TEMP_TABLE_A as (
select
t1.c1
from
Table1 t1
)select
t2.c1
from
Table2 t2
where
t2.c1 in (
select
temp.c1
from
TEMP_TABLE_A temp)
2,用exists的写法
with TEMP_TABLE_A as ( select t1.c1 from Table1 t1
)
select
t2.c1
from
Table2 t2
where
exists (
select
1
from
TEMP_TABLE_A temp
where t2.c1 = temp.c1
)
==================================解决 无用评论 打赏 举报
悬赏问题
- ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
- ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
- ¥20 有关区间dp的问题求解
- ¥15 多电路系统共用电源的串扰问题
- ¥15 slam rangenet++配置
- ¥15 有没有研究水声通信方面的帮我改俩matlab代码
- ¥15 ubuntu子系统密码忘记
- ¥15 保护模式-系统加载-段寄存器
- ¥15 电脑桌面设定一个区域禁止鼠标操作
- ¥15 求NPF226060磁芯的详细资料