Nunzio Visciano
Nunzio Visciano

Reputation: 73

JPA automatic calling analyze table x compute statitics

We are working on some legacy code based on Open Jpa 2.2 interecting with Oracle. The code automatically issues statements like:

analyze table x compute statitics

We would like to avoid this as it happens when we do not want. It this possible? If yes how?

Upvotes: 1

Views: 575

Answers (2)

Nunzio Visciano
Nunzio Visciano

Reputation: 73

This is to highlight the solution to this problem I noticed in other pieces of sw:

The problem is in getIndexInfo() metatada class method. If the fourth parameter is set to false the system will calculate exact statistics: this should be avoided especially if in subsequent steps you recalculate these statistics (this is quite common in my experience as people wants to take control of these steps).

Upvotes: 0

Jon Heller
Jon Heller

Reputation: 36902

DBMS_STATS.LOCK_TABLE_STATS can prevent statistics gathering.

--Create sample table.
create table x(a number);

--To gather stats: unlock stats, gather stats, then lock stats.
begin
    dbms_stats.unlock_table_stats(user, 'X');
    dbms_stats.gather_table_stats(user, 'X');
    dbms_stats.lock_table_stats(user, 'X');
end;
/

--Any session that tries to gather stats without unlocking gets an exception.
analyze table x compute statistics;

ORA-38029: object statistics are locked

UPDATE

This is a JDBC bug: Bug 4999817 : WHEN THE LAST FLAG TO GETINDEXINFO() IS TRUE, IT SHOULD NOT ANALYZE THE TABLE. It was fixed in 11g and there are patches for 10g. You'll need an Oracle support account to read the full details of that bug, but you've already figured out most of it.

Upvotes: 1

Related Questions