Oracle - 物化视图改变结构太慢
我有一个巨大的物质化观点,我必须调整。这是一个简单的调整,因为我只是将 NVL 函数添加到 select 语句中。
即原始...
Select this,
that.....
即修改
Select NVL(this, orThat) as this,
NVL(That, orThis) as that
该查询需要 26 秒才能运行,但由于检索的行数(230 万),速度非常慢。它连续运行了将近 5 天,然后我就停止了。
这是一个问题,特别是因为我需要将其交付给客户,而他们无法运行 5 天以上的脚本来创建 MV。
问:有什么办法可以加快MV的修改/重新制作速度?如果我修改MV会更快还是会和删除并重新创建一样?
Oracle 版本 = 10g
I have a huge materailized view that I have to adjust. It's a simple adjustment as I'm just adding an NVL function to the select statement.
I.e. Original...
Select this,
that.....
I.e. Modified
Select NVL(this, orThat) as this,
NVL(That, orThis) as that
The query takes 26 seconds to run, but due to the amount of rows retrieved (2.3 million) it is dead slow. It ran for almost 5 days straight and then I stopped it.
This is a problem, especially since I need to deliver this to a client, and they can't run a script for 5+ days to create a MV.
Question: Is there any way to speed up the altering/recreation of a MV? Would it be faster if I altered the MV or would it be around the same as dropping and recreating?
Oracle version = 10g
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法更改物化视图的查询定义 - 您必须删除并重新创建它。也就是说,您可以尝试这种方法,它可能比重新创建整个 MV 更快:
如果视图上有索引,禁用并重建它们可能会有所帮助。
You can't alter the definition of the query for a materialized view - you have to drop and recreate it. That said, you can try this approach, it could be faster than recreating the entire MV:
If you have indexes on the view, it may be helpful to disable and rebuild them.
5 天以上构建 2-300 万行 MV?这太不正常了,不仅仅是糟糕的 SQL。我的猜测是您可能被其他进程阻止(?)。不确定,但在启动 MV 重建后从另一个会话中检查这一点:
只是猜测。如果您使用 Toad,您也可以获得此信息(通过数据库 -> 监视器 -> 会话浏览器)。这还将向您显示长时间操作的进度(表扫描等)。
编辑:哦,顺便说一句,使用 nologging 构建 MV,一旦您确定没有上述问题,总体上应该会有所帮助。
5+ days to build a 2-3 million row MV? Thats waaaaay out of whack, too much to be just poor SQL. My guess is that you may be blocked by some other process(?). Not sure, but check this from a different session after you launch your MV rebuild:
Just a guess. If you use Toad you can get this info as well (via Database->monitor->session browser). This will also show you Long Ops progress (table scans, etc).
Edit: Oh, btw, build the MV using nologging, should help a bit overall once you determine that you don't have issues stated above.