几个小问题.

WEIWEILI 2004-04-09 12:00:35
1.
select * from
(select * from tgmy.c_hwda a
where a.hwid not in (select hwid from tgmy.ht_d_hwfp) ) b
where b.hwid not in (select hwid from tgmy.ht_ruk_hwls c where c.zt='预分配')
and Length(trim(b.hwcode))>=8 and substr(b.hwcode,1,2) >= '01' and substr(b.hwname,1,1) <> 'X'
order by substr(b.hwcode,1,2),substr(b.hwcode,8,1) ,substr(b.hwcode,1,7) desc

select * from
(select * from tgmy.c_hwda a
where a.hwid not in (select hwid from tgmy.ht_d_hwfp) ) b
where not exists (select 1 from tgmy.ht_ruk_hwls c where c.zt='预分配' and b.hwid = c.hwid)
and Length(trim(b.hwcode))>=8 and substr(b.hwcode,1,2) >= '01' and substr(b.hwname,1,1) <> 'X'
order by substr(b.hwcode,1,2),substr(b.hwcode,8,1) ,substr(b.hwcode,1,7) desc
执行时,有时速度快,有时速度会慢上好几倍。(相同条件下,数据量都不超过3000条)
2.
select * from
(select * from tgmy.c_hwda a
where a.hwid not in (select hwid from tgmy.ht_d_hwfp) ) b
where b.hwid not in (select hwid from tgmy.ht_ruk_hwls c where c.zt='预分配')
and Length(trim(b.hwcode))>=8 and substr(b.hwcode,1,2) >='01' and substr(b.hwname,1,1) <> 'X'
order by substr(b.hwcode,1,2), substr(b.hwcode,8,1),substr(b.hwcode,1,7) desc;
如何取出第一条。
3.
在存储过程中,建立临时表;多个人同时运行这个存储过程,会不会有影响。
...全文
24 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
WEIWEILI 2004-04-13
  • 打赏
  • 举报
回复
tg
WEIWEILI 2004-04-13
  • 打赏
  • 举报
回复
ok
shuipipi 2004-04-13
  • 打赏
  • 举报
回复
I 服了 YOUR SQL!
welyngj 2004-04-12
  • 打赏
  • 举报
回复
建立临时表会造成碎片
WEIWEILI 2004-04-12
  • 打赏
  • 举报
回复
没什么好办法?
结了。
WEIWEILI 2004-04-10
  • 打赏
  • 举报
回复
嘿嘿
怎么看啊?
beckhambobo 2004-04-10
  • 打赏
  • 举报
回复
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a90842/ch9.htm#1006527
jiezhi 2004-04-09
  • 打赏
  • 举报
回复
1.正常现象。
2.where rownum=1
3.建立的临时表是全局的,每个session互相不影响。
beckhambobo 2004-04-09
  • 打赏
  • 举报
回复
还不如利用执行计划查看
WEIWEILI 2004-04-09
  • 打赏
  • 举报
回复
还有,有时还会报超时。
select * from
(select * from tgmy.c_hwda a
where a.hwid not in (select hwid from tgmy.ht_d_hwfp) ) b
where
Length(trim(b.hwcode))>=8 and substr(b.hwcode,1,2) >= '01' and substr(b.hwname,1,1) <> 'X'
order by substr(b.hwcode,1,2),substr(b.hwcode,8,1) ,substr(b.hwcode,1,7) desc
如果这么改,速度就不会慢了。但是也达不到我要的效果了。
not in 和 not exists

not in 要进行全表扫描
而not exists 不会
可时实际使用,执行时间是一样的啊。
有优化的方法吗
WEIWEILI 2004-04-09
  • 打赏
  • 举报
回复
to : ern(学习Oracle)
不是,现在只有一个人用,是不是和设置有关



ern 2004-04-09
  • 打赏
  • 举报
回复
支持楼上
速度快慢也有可能有其他人在用数据库做大数据量操作

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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