insert union all 不能成功执行

lilinew 2010-07-08 02:24:53
mysql 执行下面的失败

nsert into subfull(time,data,des,value,newTime,newData)
select * from subscription
union all
select * from subscription1
union all
select * from subscription2
union all
select * from subscription3
union all
select * from subscription4
union all
select * from subscription5
union all
select * from subscription6
union all
select * from subscription7


如果单独执行nsert into subfull(time,data,des,value,newTime,newData)
select * from subscription是成功的 并且很快。7次 不过7分钟

但union all insert 花了半个小时不能得到结果。 为什么??



...全文
325 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
shine333 2010-07-08
  • 打赏
  • 举报
回复
没看清题目。

你量大概多少?
shine333 2010-07-08
  • 打赏
  • 举报
回复
你分7次insert ... select * from subscriptionN 可以吗
ACMAIN_CHM 2010-07-08
  • 打赏
  • 举报
回复
[Quote]但union all insert 花了半个小时不能得到结果。 为什么??[/Quote]

EXPLAIN看一下,应该是使用了临时文件。
lilinew 2010-07-08
  • 打赏
  • 举报
回复
先取结果集 select ...union all select .. 这个结果有 500万数据。

确实过大-----------------这个是原因
gxg353 2010-07-08
  • 打赏
  • 举报
回复
我认为:你的方法 sql 执行 过程:
1、先取结果集 select ...union all select .. 这个结果非常大
2、然后 insert into 这些结果集。
这个过程比较缓慢。

你插入单个表时结果集比较下,所以感觉比较快
rucypli 2010-07-08
  • 打赏
  • 举报
回复
explain

56,678

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧