Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

dbms_stats requires exclusive lock and can block other queries

864527Sep 19 2011 — edited Sep 19 2011
Here is a simple test case that illustrates a blocking issue we have with queries running against a table used in a view creation while the stats job is running on that table. Note the key is that the view create needs to start first and take more time than the stats job. It seems queries hang that are accessing the view when stats tries to update something in the library cache. Is this normal, and if so is it documented that you can't run stats and create a view at the same time?

Test case:

create table junker as select * from all_objects;
alter table junker add CONSTRAINT JUNKER_PK PRIMARY KEY (OWNER, OBJECT_NAME, OBJECT_ID)

create table junker1 as select * from all_objects;
alter table junker1 add CONSTRAINT JUNKER1_PK PRIMARY KEY (OWNER, OBJECT_NAME, OBJECT_ID)


drop materialized view junker1;
create materialized view junker1 as
select a.* from junker a, junker1 b where a.owner = b.owner


++/
BEGIN
SYS.DBMS_STATS.GATHER_TABLE_STATS (
OwnName => 'myschema'
,TabName => 'junker'
,Estimate_Percent => 5
,Degree => 1
,Cascade => TRUE
,No_Invalidate => TRUE);
END;
/

select * from junker where owner='SYS' and object_name='ICOL$'

Why does the last query hang until stats is done or the view create is done? It this explained in the documentation?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 17 2011
Added on Sep 19 2011
2 comments
519 views