简体   繁体   中英

Oracle 11g Materialized View hangs

I'm attempting to create a materialized view within Oracle using a pre-built view.

  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. 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). 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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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