请教oracle db问题

来源: simplylove 2014-06-23 09:17:36 [] [博客] [旧帖] [给我悄悄话] 本文已被阅读: 次 (582 bytes)
我有个特别complex的SQL query cursor, takes a long time (a few hours)to complete. And very often it failed with oracle error "snapshot too old rollback segment too small". 原因是我用的table data 都是changing frequently的。我就决定把里面的每个subquery 都分别写到temp table里,然后在main cursor 里在join these temp tables. 我觉得这样应该能work的。可是reviewer让我证明这样能解决问题。烦死了,query那么大又不是我的错。db 高手们有什么好主意? 除了加 table index外,query还能怎么optimize? 

所有跟帖: 

打出来看看? -slow_quick- 给 slow_quick 发送悄悄话 slow_quick 的博客首页 (0 bytes) () 06/23/2014 postreply 10:48:54

太长了 -simplylove- 给 simplylove 发送悄悄话 simplylove 的博客首页 (9 bytes) () 06/23/2014 postreply 19:02:13

加点log语句看看到底那步最耗时,再加以改进 -Guoluke2- 给 Guoluke2 发送悄悄话 Guoluke2 的博客首页 (0 bytes) () 06/23/2014 postreply 11:27:19

最大的table至少有几百个million rows -simplylove- 给 simplylove 发送悄悄话 simplylove 的博客首页 (48 bytes) () 06/23/2014 postreply 19:06:40

这就是database本身的问题了,找dba解决 -GuoLuke2- 给 GuoLuke2 发送悄悄话 GuoLuke2 的博客首页 (0 bytes) () 06/24/2014 postreply 18:52:05

回复:请教oracle db问题 -lidongmei- 给 lidongmei 发送悄悄话 lidongmei 的博客首页 (299 bytes) () 06/23/2014 postreply 12:49:56

已经有index了。我们虽然不是data warehouse数据,但数据量很大。再加additional index -simplylove- 给 simplylove 发送悄悄话 simplylove 的博客首页 (224 bytes) () 06/23/2014 postreply 19:16:51

我觉得只能用temp table了。问DBA也不做声 -simplylove- 给 simplylove 发送悄悄话 simplylove 的博客首页 (12 bytes) () 06/23/2014 postreply 19:22:21

回复:已经有index了。我们虽然不是data warehouse数据,但数据量很大。再加additional index -lidongmei- 给 lidongmei 发送悄悄话 lidongmei 的博客首页 (17866 bytes) () 06/24/2014 postreply 09:02:52

Well it is a real time system and the response time is critical. -simplylove- 给 simplylove 发送悄悄话 simplylove 的博客首页 (0 bytes) () 07/07/2014 postreply 20:25:25

Adding additional index will probably have negative impact on ou -simplylove- 给 simplylove 发送悄悄话 simplylove 的博客首页 (0 bytes) () 07/07/2014 postreply 20:26:52

这还不简单,弄不出来就别弄了,省事儿了 -南城胡同串子- 给 南城胡同串子 发送悄悄话 (66 bytes) () 06/23/2014 postreply 16:53:28

我也想不弄啊,成天串胡同儿多悠闲。可是得养家糊口啊 -simplylove- 给 simplylove 发送悄悄话 simplylove 的博客首页 (9 bytes) () 06/23/2014 postreply 19:26:49

Using cursor might not be a good idea. -chirolike- 给 chirolike 发送悄悄话 chirolike 的博客首页 (0 bytes) () 06/24/2014 postreply 16:10:27

回复:请教oracle db问题 -种豆的gua- 给 种豆的gua 发送悄悄话 (128 bytes) () 06/24/2014 postreply 20:02:30

这些都已经相当大了,DBA不给增加了。我试了temp table solution and seems it is workin -simplylove- 给 simplylove 发送悄悄话 simplylove 的博客首页 (0 bytes) () 07/07/2014 postreply 20:30:19

请您先登陆,再发跟帖!