Oracle数据库数据恢复、性能优化

找回密码
注册
搜索
热搜: 活动 交友 discuz
发新帖

0

积分

1

好友

29

主题
1#
发表于 2013-3-6 14:36:21 | 查看: 3108| 回复: 3
本帖最后由 张沛 于 2013-3-6 15:10 编辑

昨天看了一本书,大致写的是
“一个查询对一张临时表查询进行了10次扫描,改下一sql的存储过程,就只需要一遍,例子:
select 'A' ,count(*) from TMP where status='A union all
select 'B' ,count(*) from TMP where status='B' union all
select 'C' ,count(*) from TMP where status='C' union all
select 'D' ,count(*) from TMP where status='D' union all
”存储过程如下
declear
va:integer; vb :intger; vc:integer;vd:integer;
begin va:=0;vb:=0;vc:=0;vd:=0;
for c in (select status from TMP) loop
if c.status='a' then va:=va+1
else
if c.status='b' then va:=vb+1
else
if c.status='c' then va:=vc+1
else
if c.status='d' then va:=vd+1
end if;
end if;
end if;
end if;
end loop;
.....
end;
例子中是oltp的一张临时表,如果换成olap的大表这种方法适不适合?
2#
发表于 2013-3-6 15:28:42
group by OK?

回复 只看该作者 道具 举报

3#
发表于 2013-3-6 15:49:15
Ling.QIu 发表于 2013-3-6 15:28
group by OK?

额,我知道了,我就是对我说的那个例子还有点疑问..嘿嘿

回复 只看该作者 道具 举报

4#
发表于 2013-3-6 16:37:30
张沛 发表于 2013-3-6 15:49
额,我知道了,我就是对我说的那个例子还有点疑问..嘿嘿

有问题继续提

回复 只看该作者 道具 举报

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

QQ|手机版|Archiver|Oracle数据库数据恢复、性能优化

GMT+8, 2024-6-1 22:06 , Processed in 0.051454 second(s), 20 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部
TEL/電話+86 13764045638
Email service@parnassusdata.com
QQ 47079569