Database Tuning (MOSC)

MOSC Banner

Histograms: 32 character limit generates inaccurate stats

edited Jun 12, 2018 3:54PM in Database Tuning (MOSC) 2 commentsAnswered
 Hi guys,

The following entry is in the crontab :

$ crontab -l | grep fix
0 7 * * * /usr/mvf/fix_uid_bug.sh >/dev/null

		


The contents of the script executed are as follows:

$ cat /usr/mvf/fix_uid_bug.sh
#!/bin/bash
. /usr/mvf/.bashrc

echo "execute sys.fix_uid_bug;"| sqlplus dbadmin/dbadmin
		


And the contents of the stored procedure that the script runs is listed below:

SQL> set pagesize 0;

SQL> select text from dba_source where name='FIX_UID_BUG';

procedure fix_uid_bug
as
n1 pls_integer;
n2 pls_integer;

begin

select num_rows into n1 from dba_tables where table_name='T1';

select num_rows into n2 from dba_tables where table_name = 'T2';

if n1 <> 0 then

DBMS_STATS.SET_COLUMN_STATS(ownname=>'DBADMIN', tabname=>'T1',colname=>'COL1',distcnt=>n1,density=>1/n1);

end if;

if n2 <> 0 then
DBMS_STATS.SET_COLUMN_STATS(ownname=>'DBADMIN', tabname=>'T2',colname=>'COL2',distcnt=>n2,density=>1/n2);

end if;

execute immediate 'alter system flush shared_pool';

end;

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center