有个SQL视图为
select a1,a2 from a
union
select b1,b2 from b
union
select c1,c2 from c
union
select d1,d2 from d
记录才两万多都要了11秒,怎么能提高效率速度
select a1,a2 from a
union
select b1,b2 from b
union
select c1,c2 from c
union
select d1,d2 from d
记录才两万多都要了11秒,怎么能提高效率速度
2、如果没必要的话,把union改成union all
你可以尝试把union改为union all,时间是否会少一些?
每个语句后面跟上where 最后union all连接效率高
不需要where 改为union all后还是一样,每个表都有主键
2.在这视图上加索引