Auto sample gather stats procedure

Hi,
can some one explain the  Oracle's auto sample gather stats procedure and how to run it.

Thanks
taazAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sdstuberCommented:
it doesn't exist in 9i, you have to invoke dbms_stats yourself.  You can schedule it to run automatically yourself via dbms_job if you want.

it does exist in 10g and you don't have to do anything because it runs automatically via dbms_scheduler.
What the procedure does is count the rows in your tables and indexes, or at least sampling them if they are very large.  It also gathers some statistical information to describe the data in each table such as min and max value, number of nulls, distribution of values into histograms and count of associated index values.  It will also gather some system statistics so the optimizer will know how fast your cpu is, how fast the io, etc.
0
Naveen KumarProduction Manager / Application Support ManagerCommented:
in 10g database, you can use the below queries to see what the job calls and when the job runs etc....

select * from dba_scheduler_jobs
where owner ='SYS'
and job_name = 'GATHER_STATS_JOB'

select * from dba_scheduler_programs
where owner ='SYS'
and program_name ='GATHER_STATS_PROG'

select * from dba_scheduler_schedules
where owner ='SYS'

select * from dba_scheduler_window_groups;

also to check the log,  use the below :

select * from dba_scheduler_job_run_details
where owner ='SYS'
and job_name ='GATHER_STATS_JOB'
order by 1 desc

select * from dba_scheduler_job_log
where owner ='SYS'
and job_name ='GATHER_STATS_JOB'
order by 1 desc
0
taazAuthor Commented:
Thanks Sdstuber and  Mav Kum V I really appreciate you.
I will let you know once I run these queries.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

schwertnerCommented:
I use the following code to compute statistics:

/*
** To run automatically statistics computing on
** middnight today and every week after that also on middnight
** run in SQL*Plus as user SYS the following script
** Write down the number returned by the script.
** It should be used to point the queued job
** for operations like delete, reschedule, etc.
** when using the DBMS_JOB package
*/


CREATE OR REPLACE PROCEDURE compute_statistics IS
BEGIN
   dbms_stats.gather_database_stats(cascade=>true);
END compute_statistics;
/


set serveroutput on
set linesize 10000
variable x number;
begin
   DBMS_OUTPUT.enable(100000);  
   dbms_job.submit(:x,'compute_statistics;',trunc(sysdate),'trunc(sysdate+7)');
   commit;
   dbms_output.put_line(TO_char(:x));
end;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
taazAuthor Commented:
Thanks It worked.

Sorry for the late response.
0
sdstuberCommented:
hmmm, odd answer to accept.

the first two posts actually answered your question about the 10g automatic gathering of statistics.

the answer you accepted is the exact opposite, it shows how to do it manually.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.