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 MV_REFRESH_ATOMICITY_TEST
(
id NUMBER,
value NUMBER
)
declare
begin
for i in 1..10000000 loop
insert into MV_REFRESH_ATOMICITY_TEST values(i, 0);
end loop;
end;
select sum(value) from MV_REFRESH_ATOMICITY_TEST
select to_char(count(*),'999,999,999') as COUNT from MV_REFRESH_ATOMICITY_TEST
create materialized view log on MV_REFRESH_ATOMICITY_TEST with rowid;
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
select sum(value) from MV_REFRESH_ATOMICITY_TEST_MV
select to_char(count(*),'999,999,999') as COUNT from MV_REFRESH_ATOMICITY_TEST_MV
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
select to_char(sum(value),'999,999,999') as "SUM" from MV_REFRESH_ATOMICITY_TEST
select to_char(count(*),'999,999,999') from MLOG$_MV_REFRESH_ATOMICITY;
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, . , .