sql优化问题 斑竹请进

[复制链接]
查看11 | 回复9 | 2007-8-25 20:02:41 | 显示全部楼层 |阅读模式
1.insert /*+append*/into table1select * from table2;
--用时: 6分钟

2. alter session enable parallel dml;
insert /*+paralllel(a,2)*/ into table1 a select * from table2;
--用时: 9分钟

table2有200w条数据,现在想插入到table1,为什么1 比 2快了竟然3分钟?
说明: 数据库的服务器有2个cpu
回复

使用道具 举报

千问 | 2007-8-25 20:02:41 | 显示全部楼层
还和磁盘i / o有关系。
-----------------------------------------------------------------
Parallel Direct-Path INSERT into a Nonpartitioned Table
Each parallel execution server allocates a new temporary segment and inserts data into that temporary segment. When a COMMIT executes, the parallel execution coordinator merges the new temporary segments into the primary table segment, where it is visible to users.
回复

使用道具 举报

千问 | 2007-8-25 20:02:41 | 显示全部楼层
那应该怎样设置才使得2比1快呢
回复

使用道具 举报

千问 | 2007-8-25 20:02:41 | 显示全部楼层
insert /*+ append paralllel(a,2) */ into table1 a select * from table2;
回复

使用道具 举报

千问 | 2007-8-25 20:02:41 | 显示全部楼层
to space6212
insert /*+paralllel(a,2)*/ into table1 a select * from table2;

insert /*+ append paralllel(a,2) */ into table1 a select * from table2;
是一样的吧,因为parallel包含了append
回复

使用道具 举报

千问 | 2007-8-25 20:02:41 | 显示全部楼层
你的机器有几个CPU?
回复

使用道具 举报

千问 | 2007-8-25 20:02:41 | 显示全部楼层
原帖由 chenzhanyiasd 于 2008-7-26 19:28 发表
to space6212
insert /*+paralllel(a,2)*/ into table1 a select * from table2;

insert /*+ append paralllel(a,2) */ into table1 a select * from table2;
是一样的吧,因为parallel包含了append


append 和parallael连用,会影响PARALLEL的
参考这个
http://dba.ipbhost.com/index.php?&showtopic=2541
using the APPEND hint may cause serialization,
removing the benefit of parallel jobstreams
[ 本帖最后由 wangfans 于 2008-7-26 22:53 编辑 ]
回复

使用道具 举报

千问 | 2007-8-25 20:02:41 | 显示全部楼层
谁能解答一下?晕啊。。。。。
回复

使用道具 举报

千问 | 2007-8-25 20:02:41 | 显示全部楼层
因为在PARALLEL下,APPEND会有个队列,也就是说让PARALLEL process 排队,所以,PARALLEL失去了很多优势
回复

使用道具 举报

千问 | 2007-8-25 20:02:41 | 显示全部楼层
具体我也没有验证,我看到过这个帖子(前面那个连接),
我将上面的话,翻译了下~~
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行