[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 705
  • Last Modified:

Auto sample gather stats procedure

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

Thanks
0
taaz
Asked:
taaz
1 Solution
 
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now