Oracle: materialized view of atom fast update?

I have read quite a lot over the past few hours about updating MVs in Oracle, but I cannot find the answer to my question. Imagine I have an MV view on top of a table with change logs. So there are three entries in this MV:

COL_ID, COL1
1, "OLD"
2, "OLD"
3, "OLD"

Now let's say that the value for COL1 has changed to "EDITED" for entry 1 in the table used to create the MV. I want to perform the update quickly , in place , to update the MV as quickly as possible. In real life, an example with 50M records, it takes about 3 minutes to update.

Imagine a situation.

  • The update process is still running (there are records that have not been changed in MV).
  • pmls, the entry with id = 1 has already been processed, so it has the value "EDITED" in MV.
  • In another session, a request is made to MV to get the record value with identifier ID = 1.

How will the result be written with the value "OLD" or "EDITED"?

, , , , ( "EDITED" ). - (, ), ? , ( ), , , - .

, bevahiour , , , , , . , ?

----- [EDIT]

, , , , .

-- create table
create table MV_REFRESH_ATOMICITY_TEST
(
  id    NUMBER,
  value NUMBER
)

-- populate initial data
-- delete from MV_REFRESH_ATOMICITY_TEST
declare
begin
   for i in 1..10000000  loop
       insert into MV_REFRESH_ATOMICITY_TEST values(i, 0);
   end loop;  
end;

-- check if equal zero and 1M
select sum(value) from MV_REFRESH_ATOMICITY_TEST
select to_char(count(*),'999,999,999') as COUNT from MV_REFRESH_ATOMICITY_TEST       

-- create mv logs on the table
-- drop materialized view log on MV_REFRESH_ATOMICITY_TEST;     
create materialized view log on MV_REFRESH_ATOMICITY_TEST with rowid;     

-- create mv on top
-- drop materialized view MV_REFRESH_ATOMICITY_TEST_MV
create materialized view MV_REFRESH_ATOMICITY_TEST_MV
refresh fast on demand with rowid
as
select
       fact.*,
       fact.ROWID "FACT_ROWID"
from
       MV_REFRESH_ATOMICITY_TEST fact

-- check if equals zero and 10M
select sum(value) from MV_REFRESH_ATOMICITY_TEST_MV       
select to_char(count(*),'999,999,999') as COUNT from MV_REFRESH_ATOMICITY_TEST_MV     

-- change value for first million records, 1 milion records in the middle, last milion of records
update MV_REFRESH_ATOMICITY_TEST set value = 1 where id between 1 and 1000000
update MV_REFRESH_ATOMICITY_TEST set value = 1 where id between 5000001 and 6000000
update MV_REFRESH_ATOMICITY_TEST set value = 1 where id between 9000001 and 10000000

-- check if equals 3.000.000
select to_char(sum(value),'999,999,999') as "SUM" from MV_REFRESH_ATOMICITY_TEST

-- check if equals 3.000.000
select to_char(count(*),'999,999,999') from MLOG$_MV_REFRESH_ATOMICITY;  
--select * from MLOG$_MV_REFRESH_ATOMICITY;

-- while refreshing mv
-- exec dbms_mview.refresh('MV_REFRESH_ATOMICITY_TEST_MV', 'F');
-- below sum should be equal 0
select 
   ( select sum(value) from MV_REFRESH_ATOMICITY_TEST_MV ) "SUM",
   ( select count(*) from MV_REFRESH_ATOMICITY_TEST_MV ) "NUMBER OF RECORDS"  
from dual

, , select, , , SUM , 3M, - .

, 100% , , - 40 . 911.

[EDIT]

. , , , , -, fast-refresh, . , .

+4
1
+2

All Articles