我有个特别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?
请教oracle db问题
所有跟帖:
•
打出来看看?
-slow_quick-
♂
(0 bytes)
()
06/23/2014 postreply
10:48:54
•
太长了
-simplylove-
♀
(9 bytes)
()
06/23/2014 postreply
19:02:13
•
加点log语句看看到底那步最耗时,再加以改进
-Guoluke2-
♂
(0 bytes)
()
06/23/2014 postreply
11:27:19
•
最大的table至少有几百个million rows
-simplylove-
♀
(48 bytes)
()
06/23/2014 postreply
19:06:40
•
这就是database本身的问题了,找dba解决
-GuoLuke2-
♂
(0 bytes)
()
06/24/2014 postreply
18:52:05
•
回复:请教oracle db问题
-lidongmei-
♂
(299 bytes)
()
06/23/2014 postreply
12:49:56
•
已经有index了。我们虽然不是data warehouse数据,但数据量很大。再加additional index
-simplylove-
♀
(224 bytes)
()
06/23/2014 postreply
19:16:51
•
我觉得只能用temp table了。问DBA也不做声
-simplylove-
♀
(12 bytes)
()
06/23/2014 postreply
19:22:21
•
回复:已经有index了。我们虽然不是data warehouse数据,但数据量很大。再加additional index
-lidongmei-
♂
(17866 bytes)
()
06/24/2014 postreply
09:02:52
•
Well it is a real time system and the response time is critical.
-simplylove-
♀
(0 bytes)
()
07/07/2014 postreply
20:25:25
•
Adding additional index will probably have negative impact on ou
-simplylove-
♀
(0 bytes)
()
07/07/2014 postreply
20:26:52
•
这还不简单,弄不出来就别弄了,省事儿了
-南城胡同串子-
♂
(66 bytes)
()
06/23/2014 postreply
16:53:28
•
我也想不弄啊,成天串胡同儿多悠闲。可是得养家糊口啊
-simplylove-
♀
(9 bytes)
()
06/23/2014 postreply
19:26:49
•
Using cursor might not be a good idea.
-chirolike-
♂
(0 bytes)
()
06/24/2014 postreply
16:10:27
•
回复:请教oracle db问题
-种豆的gua-
♂
(128 bytes)
()
06/24/2014 postreply
20:02:30
•
这些都已经相当大了,DBA不给增加了。我试了temp table solution and seems it is workin
-simplylove-
♀
(0 bytes)
()
07/07/2014 postreply
20:30:19