简体   繁体   English

Oracle 11g物化视图挂起

[英]Oracle 11g Materialized View hangs

I'm attempting to create a materialized view within Oracle using a pre-built view. 我正在尝试使用预先构建的视图在Oracle中创建实例化视图。

  create materialized view bfb_rpt_sch01.mvw_base_sales
  as select * from bfb_rpt_sch01.vw_base_sales;

This command will not execute and hangs. 该命令将不会执行并挂起。 I figured perhaps this has something to do with the view not being properly written. 我认为这可能与未正确编写视图有关。 So I performed the following query on the view. 因此,我在视图上执行了以下查询。

  select count(*) from bfb_rpt_sch01.vw_base_sales

This query takes about 6 minutes to execute and returns 2.7 million. 该查询执行大约需要6分钟,并返回270万。 This tells me the view is not the issue, but I could be wrong. 这告诉我观点不是问题,但我可能是错的。

I managed to figure out my issue. 我设法弄清楚了我的问题。 My (CREATE MATERIALIZED VIEW AS) was using a different explain compared to my (CREATE TABLE AS). 与我的(创建表AS)相比,我的(创建材料视图AS)使用的解释不同。 If my code contained the follow line of code, it would run completely fine as (CREATE TABLE AS), but it would continue to hang for 48+ hrs before it would fail when using (CREATE MATERIALIZED VIEW AS). 如果我的代码包含以下代码行,则可以像(CREATE TABLE AS)一样正常运行,但是在使用(CREATE MATERIALIZED VIEW AS)失败之前,它将继续挂起48小时以上。

WHERE a.column_name NOT IN (SELECT b.column_name FROM B) --culprit

I changed the code using the following and it now works fine. 我使用以下代码更改了代码,现在可以正常工作了。

WHERE NOT EXISTS (SELECT NULL FROM B WHERE a.column_name = b.column_name) --works

I'm not sure why this happens, perhaps bug? 我不确定为什么会发生这种情况,也许是错误? I don't enough about ORACLE to make the call. 我对ORACLE的电话还不够。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM