Tuesday, August 26, 2008

lock statistics

[symptom]

Complete gathering statistics for schema or whole database within few minutes, which is not supposed to , as the data size is more than 100Gb. There is no error message prompted.

checked last_analyzed from dba_tables, it is null.

[Troubleshooting]

SQL> ANALYZE TABLE SYS.T1 COMPUTE statistics;
ANALYZE TABLE SYS.T1 COMPUTE statistics
*
ERROR at line 1:
ORA-38029: object statistics are locked


Now realized , the statistics is locked.


SQL> exec dbms_stats.unlock_table_stats('SYS','T1');

PL/SQL procedure successfully completed.

SQL> ANALYZE TABLE SYS.T1 COMPUTE statistics;

Table analyzed.



[More Info]
You may also lock statistics at the schema level using the LOCK_SCHEMA_STATS procedure.

You may determine if a table's statistics are locked by querying the STATTYPE_LOCKED column in the
{USER | ALL | DBA}_TAB_STATISTICS view

To unlock the tables statitics for a specified table you may use the UNLOCK_TABLE_STATS procedure.