| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Why ORA-1555 snapshot too old.
One of my developers is trying to query a 45g table that is constantly being
insert into. He wants to get a count of rows that meet a certain criteria.
Of couse he got ORA-1555 snapshot too old. I told him to query smaller
sections of the table and total up the counts for the individual sections so
he wrote a PL/SQL block to do that. It loops through table selecting 1000
rows at a time. Each of these queries finishes in seconds but he is still
getting ora-1555 though. Why? According to Oracle's documentation under the
"set transaction" command they use"statement-level read consistency". Isn't
each separate execution of the select a new statement? I know the RBS is not
wrapping back on itself in that short of a time and it is not shrinking
either.
Here's the jist of his code...
# Next two statements finish in milliseconds. No 1555 error here
select min(pk) into starting_pk from table;
select max(pk) into max_pk from table;
while starting_pk <= max_pk
loop
ending_pk := starting_pk + 999;
# Following statment is where ora-1555 occurs sometimes.
select count(*) into c from table where pk between starting_pk and ending_pk and other_criteria = true;
grand_total := grand_total + c;
starting_pk := starting_pk + 1000;
end loop;
dbms_output.put_line('Grand total is '||grand_total);
/
Received on Fri Oct 18 2002 - 15:25:35 CDT
![]() |
![]() |