Histograms: 32 character limit generates inaccurate stats [message #376234] |
Tue, 16 December 2008 09:47 |
zaff
Messages: 50 Registered: July 2008
|
Member |
|
|
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;
we were informed that this script is run to address a deficiency in Oracle whereby the statistics gathering only looks at the first 32 bytes of a character column when creating the statistics histogram, and since study_uid’s are generally over 32 characters in length (with many of the first 32 characters being the same), this produces skewed statistics, adversely affecting the query planner and producing suboptimal, slow query plans.
Is there a better way of obtaining accurate stats rather than using the process above i.e. manual updates of stats?
Is there a way of increasing the 32 character limit on histograms?
Thanks in advance,
Zabair
[Updated on: Tue, 16 December 2008 09:58] Report message to a moderator
|
|
|
|
|
|