Automate Statistics Gathering (9i)

Hi All,
Which one of the following two approaches is recommended for Gathering Daily SCHEMA Level Statistcs in the DB.
1. Create a CRONJOB that runs
exec dbms_stats.gather_schema_stats('MYSCHEMA'); at a scheduled time (Off Peak Hours) daily?
2. Or use DBMS_JOB to schedule the same script?
What I basically want to know is does scheduling jobs via cron has any added benefit?
Regards,
Chinmay

Really I think it depends on what you are more comfortable with.
I like putting my jobs like this in cron that way it is very easy for me to see and transfer to another system. I like the control to allow me to schedule it for different days and times in the day quickly. However, it was pointed out that this can be a security issue depending on how you set things up.
Regards
Tim

Similar Messages

  • How to disable automatic statistics collections on tables

    Hi
    I am using Oracle 10g and we have few tables which are frequently truncated and news rows added to it. Oracle automatically analyzes the table by some means which collects statistics of the table but at the wrong time(when the table is empty). This makes my query to do a full table scan rather using indexes since the statistics was collected when the table was empty.Could any one please let me know how to disable the automatic statistics collection feature of Oracle?
    Cheers
    Anantha PV

    Hi
    I am using Oracle 10g and we have few tables which
    are frequently truncated and news rows added to it.
    Oracle automatically analyzes the table by some means
    which collects statistics of the table but at the
    wrong time(when the table is empty). This makes my
    query to do a full table scan rather using indexes
    since the statistics was collected when the table was
    empty.Could any one please let me know how to disable
    the automatic statistics collection feature of
    Oracle?
    First of all I think it's important that you understand why Oracle collects statistics on these tables: Because it considers the statistics of the object to be missing or stale. So if you just disable the statistics gathering on these tables then you won't have statistics at all or outdated statistics.
    So as said by the previous posts you should gather the statistics manually yourself anyway. If you do so right after loading the data into the truncated table, you don't need to disable the automatic statistics gathering as it only processes objects that are stale or don't have statistics at all.
    If you still think that you need to disable it there are several ways to accomplish it:
    As already mentioned, for particular objects you can lock the statistics using DBMS_STATS.LOCK_TABLE_STATS, or for a complete schema using DBMS_STATS.LOCK_SCHEMA_STATS. Then these statistics won't be touched by the automatic gathering job. You still can gather statistics using the FORCE=>true option of the GATHER__STATS procedures.
    If you want to change the automatic gathering job that it only gathers statistics on objects owned by Oracle (data dictionary, AWR etc.), then you can do so by calling DBMS_STATS.SET_PARAM('AUTOSTATS_TARGET', 'ORACLE'). This is the recommended method.
    If you disable the schedule job as mentioned in the documentation by calling DBMS_SCHEDULER.DISABLE('GATHER_STATS_JOB') then no statistics at all will be gathered automatically, causing your data dictionary statistics to be become stale over time, which could lead to suboptimal performance of queries on the data dictionary.
    All this applies to Oracle 10.2, some of the features mentioned might not be available in Oracle 10.1 (as you haven't mentioned your version of 10g).
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle:
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Automatic statistics generation in 11.2

    Dear experts!
    I've initialized the automatic statistics collector in my 11.2 db as follows:
    BEGIN
    DBMS_AUTO_TASK_ADMIN.ENABLE(
    client_name => 'auto optimizer stats collection',
    operation => NULL,
    window_name => NULL);
    DBMS_SCHEDULER.SET_ATTRIBUTE('SYS.MONDAY_WINDOW', 'repeat_interval', 'freq=daily;byday=MON;byhour=11;byminute=0;bysecond=0');
    DBMS_SCHEDULER.SET_ATTRIBUTE('SYS.WEDNESDAY_WINDOW', 'repeat_interval', 'freq=daily;byday=WED;byhour=11;byminute=0;bysecond=0');
    DBMS_SCHEDULER.SET_ATTRIBUTE('SYS.FRIDAY_WINDOW', 'repeat_interval', 'freq=daily;byday=FRI;byhour=11;byminute=0;bysecond=0');
    DBMS_SCHEDULER.SET_ATTRIBUTE('SYS.THURSDAY_WINDOW', 'repeat_interval', 'freq=daily;byday=THU;byhour=11;byminute=0;bysecond=0');
    DBMS_SCHEDULER.SET_ATTRIBUTE('SYS.TUESDAY_WINDOW', 'repeat_interval', 'freq=daily;byday=TUE;byhour=11;byminute=0;bysecond=0');
    DBMS_STATS.GATHER_SCHEMA_STATS(ownname => 'DBUSER',
    options => 'GATHER AUTO',
    estimate_percent => dbms_stats.auto_sample_size
    END;
    After this initial procedure the automatic maintenance task checks from monday to friday at 11 am if the statistics of the database objects are still ok. For objects with old statistics they are newly generated.
    The first question is with which parameters the automatic maintenance task executes the dbms_stats.gather_... for the objects with old statistics. In my opinion it'll take the same options as specified in the initial procedure (options=GATHER AUTO and estimate_percent=dbms_stats.auto_sample_size). Am I right?
    The second question belongs also to the parameter of the dmbs_stats procedure - but in another context:
    Some used tools generate statistics too after intensive workload, they execute the following:
    execute DBMS_STATS.GATHER_SCHEMA_STATS(ownname => 'DBUSER',
    options => 'GATHER EMPTY',
    estimate_percent => 70
    execute DBMS_STATS.GATHER_SCHEMA_STATS(ownname => 'DBUSER',
    options => 'GATHER STALE',
    estimate_percent => 70
    So what happens to my automatic maintenance task after these two procedure calls? Do these two procedures overwrite the inital provided option (GATHER AUTO) which is required for automatic statistics collection? If yes does it mean that the automatic statistics collector doesn't maintain the database objects any more?
    Thanks for your help!
    Best regards!
    Markus

    1. There is a database and table option called MONITORING. By default this is turned on from 10g. So database is watching for changes and will collect statistics on tables/objects where needed in GATHER AUTO option.
    2. No GATHER AUTO options wont be touched but you recollect stats on objects you specified in function/procedure call. And if those objects wont change in the future AUTO GATHER may wont touch these stats anymore....
    This is a doc reference list I created when I was working on similar issue. :)
    Best Practices for automatic statistics collection on Oracle 10g [ID 377152.1]
    https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&doctype=BULLETIN&id=377152.1
    How to check what automatic statistics collection is scheduled on 10g [ID 377143.1]
    https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&id=377143.1
    How To Extend Maintenance Windows For GATHER_STATS_JOB for More Than 8 Hours? [ID 368475.1]
    https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&id=368475.1
    Oracle 10g PL/SQL Packages and Types Reference - DBMS_SCHEDULER documentation
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sched.htm#CIHHBGGI
    Oracle 10g PL/SQL Packages and Types Reference - DBMS_STATS documentation
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_stats.htm#CIHBIEII
    Oracle® Database Performance Tuning Guide 10g Release 2 (10.2) 14 Managing Optimizer Statistics 14.2 Automatic Statistics Gathering
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/stats.htm#i41282
    Statistics Best Practices: How to Backup and Restore Statistics [ID 464939.1]
    https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&id=464939.1
    Managing CBO Stats during an upgrade to 10g or 11g [ID 465787.1]
    https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&doctype=HOWTO&id=465787.1

  • Dbms_stats or automatic statistics.

    Hi members,
    We are using 10g database. I am aware that 10g collects statistics automatically using its job scheduling process. Do we still need to schedule statistics collection using dbms_stats or analyze on our 10gR2 database? Is it redundant? In what situations is it required?

    You either want statistics to be gathered by the Oracle background job (which is calling dbms_stats) or you want to control statistics gathering via a job you control. Having both would be, at best, redundant, and would likely eventually cause problems.
    There is probably an 80/20 rule here. 80% of organizations with 80% of the databases probably want to keep the default settings. For the remaining 20%, you may want to change the DBMS_STATS default settings (i.e. you may need to gather fewer histograms). You may want to gather stats as part of your nightly loads (i.e. a data warehouse). You may have a preferred scheduling tool that is not the database that you want to control statistics gathering for operational reasons.
    As an aside, you should not be using ANALYZE to gather object statistics. That has been depricated for quite some time.
    Justin

  • How stop the automatic statistics collection job after the maintenance wind

    Hi,
    we are for a solution to stop the automatic statistics collection job after the maintenance window finished.
    we disable all jobs except the automatic statistics collection, because this is the only one we want to run. Then we define specific values for the interval and duration parameters of the maintenance window to customize this task.
    But for their systems it is very important that this job/task will immediately stop when the window is closed!!!
    So, how could we ensure this behavior.
    For Oracle 10g it is easy because the statistic job always exists and it is possible to set its duration and create an addtional event based job which kills all jobs that are running over duration.
    In Oracle 11g the statistic job is created by the system during the maintenance window is open.
    We are not able to modify parameters of this system job. After the maintenance window closed the job is already running - only with another resource priority - but it is running.
    Please help me in this scenario
    Thanks&Regards
    Prem

    ?So basically you are saying is if none of the tables are changed then GATHER_STATS_JOB will not run, but i see tables are updated still the job is not running. I did >query dba_scheduler_jobs and the state of the job is true and scheduled. Please see my previous post on the output
    Am i missing anything here, do i look for some parameters settings
    So basically you are saying is if none of the tables are changed then GATHER_STATS_JOB will not run,GATHER_STATS_JOB will run and if there are any table in which there's a 10 percent change in data, it will gather statistics on that table. If no table data have changes less than 10 percent, it will not gather statistics.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/stats.htm#i41282
    Hope this helps.
    -Anantha

  • Cgi statistics gathering under 6.1 and Solaris 9

    Hello all,
    is it possible to log for cgi requests the value for handling each of the time spent on the request?
    I see a lot of editable parameters in the 'Performance, Tuning and Scaling Guide' but can't figure out how to do that.
    Once in a thread I read "...enable statistics gathering, then add %duration% to your access log format line".
    I can't find the terminus %duration% in the guide, which parameter is taken?
    Regards Nick

    Hello elvin,
    thanks for your reply. Now I think I managed to let the webserver log the duration of a cgi request, but I'm unsure how to interpret the value eg. in the access log I get
    ..."GET /cgi/beenden.cgi ... Gecko/20040113 MultiZilla/1.6.3.1d" 431710"
    ..."GET /pic.gif ... Gecko/20040113 MultiZilla/1.6.3.1d" 670"
    so the last value corresponds to my %duration% in the magnus.conf.
    431710 ... in msec? - makes no sense
    670 ... in msec?
    The complete string in magnus.conf reads as follows:
    Init fn="flex-init" access="$accesslog" format.access="%Ses->client.ip% - %Req->vars.auth-user% [%SYSDATE%] \"%Req->reqpb.clf
    -request%\" %Req->srvhdrs.clf-status% %Req->srvhdrs.content-length% \"%Req->headers.user-agent%\" \%duration%\""Regards Nick

  • Statistics gathering

    Hello ,
    Every one I'm little confuse about "Statistics gathering" in ebs so I have some question in my mind which are following.
    kindly any one clear my concept about it.I really appreciate you.
    1.What is Statistics gathering ?
    2. What is the benefit of it?
    3.Can after this our ERP performance is better?
    one question is out this subject is that can If any one wanna APPS DBA then who must be DBA(oracle 10g,9i etc) or who only have a concept of oracle dba like backup,recovery,cloning etc.
    Regards,
    Shahbaz khan

    1.What is Statistics gathering ?
    Statistics gathering is a process by which Oracle scans some or all of your database objects (such as tables, indexes etc.) and stores the information in objects such as dbal_tables, dba_histograms. Oracle uses this information to determine the best execution path for statements it has to execute (such as select, update etc.)
    2. What is the benefit of it?
    It does help the queries become more efficient.
    3.Can after this our ERP performance is better?
    Typically, if you are experiencing performance issues, this is one of the first remedies.
    one question is out this subject is that can If any one wanna APPS DBA then who must be DBA(oracle 10g,9i etc) or who only have a concept of oracle dba like backup,recovery,cloning etc.I will let Hussein or Helios answer that question. They can offer a lot of helpful advice. You can also refer to Hussein's recent thread on a similar topic.
    See Re: Time Management and planned prep
    Hope this helps,
    Sandeep Gandhi

  • Setting of Optimizer Statistics Gathering

    I'm checking in my db setting and database is analysing each day. But as I notice there are a lot of tables that information shows last analysis in about month ago... Do I have to change some parameters?

    lesak wrote:
    I don't have any data that show you that my idea is good. I'd like to confirm on this forum that my idea is good or not. I've planned to make some changes to have better performance of query that read from top use tables. If this is bad solutions it's also important information for me.One point of view is that your idea is bad. That point of view would be to figure out what the best access for your query is and set that as a baseline, or figure out what statistics get you the correct plans on a single query that has multiple plans that are best with different values sent in through bind variables, and lock the statistics.
    Another point of view would be to gather current plans for currently used queries, then do nothing at all unless the optimizer suddenly decides to switch away from one, then figure out why.
    Also note the default statistics gathering is done in a window, if you have a lot of tables changing it could happen that you can't get stats in a timely fashion within the window.
    Whether the statistics gathering is appropriate may depend on how far off histograms are from describing the actual data distribution you see. What my be appropriate worry for one app may be obsessive tuning disorder for another. 200K rows out of millions may make no difference at all, or may make a huge difference if the newly added data is way off from what the statistics make the opitmizer think it is.
    One thing you are probably doing right is to recognize that tuning particular queries may be much more useful than obsessing over statistics.
    Note how much I've used the word "may" here.

  • How to check the progress of statistics gathering on a table?

    Hi,
    I have started the statistics gathering on a few big tables in my database.
    How to check the progress of statistics gathering on a table? Is there any data dictionary views or tables to monitor the progress of stats gathering.
    Regds,
    Kunwar

    Hi all
    you can check with this small script.
    it lists the sid details for long running session like
    when it started
    when last update
    how much time still left
    session status "ACTIVE/INACTIVE". etc.
    -- Author               : Syed Kaleemuddin_
    -- Script_name          : sid_long_ops.sql
    -- Description          : list the sid details for long running session like when it started when last update how much time still left.
    set lines 200
    col OPNAME for a25
    Select
    a.sid,
    a.serial#,
    b.status,
    a.opname,
    to_char(a.START_TIME,' dd-Mon-YYYY HH24:mi:ss') START_TIME,
    to_char(a.LAST_UPDATE_TIME,' dd-Mon-YYYY HH24:mi:ss') LAST_UPDATE_TIME,
    a.time_remaining as "Time Remaining Sec" ,
    a.time_remaining/60 as "Time Remaining Min",
    a.time_remaining/60/60 as "Time Remaining HR"
    From v$session_longops a, v$session b
    where a.sid = b.sid
    and a.sid =&sid
    And time_remaining > 0;
    Sample output:
    SQL> @sid_long_ops
    Enter value for sid: 474
    old 13: and a.sid =&sid
    new 13: and a.sid =474
    SID SERIAL# STATUS OPNAME START_TIME LAST_UPDATE_TIME Time Remaining Sec Time Remaining Min Time Remaining HR
    474 2033 ACTIVE Gather Schema Statistics 06-Jun-2012 20:10:49 07-Jun-2012 01:35:24 572 9.53333333 .158888889
    Thanks & Regards
    Syed Kaleemuddin.
    Oracle Apps DBA
    Mobile: +91 9966270072
    Email: [email protected]

  • Understand Oracle statistics gathering

    Hi experts,
    I am new in Oracle performance tuning. can anyone tell me what the mean of "Oracle statistics gathering" in simple words/way. i has read it from Oracle site http://docs.oracle.com/cd/A87860_01/doc/server.817/a76992/stats.htm.
    But i am not understand it properly. It Any role in oracle performance tuning? Does it make good performance of Oracle DB???
    Reg
    Harshit

    Hi,
    You can check this in some Easy way :ORACLE-BASE - Oracle Cost-Based Optimizer (CBO) And Statistics (DBMS_STATS)
    >> It Any role in oracle performance tuning? Does it make good performance of Oracle DB???  :Yes
    HTH

  • Automatic stats gathering

    Hi:
    I am on 10.2.0.3 and use Automatic stats gathering with statistics_level=Typical, but some of my collegaues say that they "colud not trust Oracle to do this job". We are running PeopleSoft Finacials and HR (practically every module) and things seem fine.
    I'd like to get a general feel on this issue. Do you guys us that or run your own scripts? Anybody knows some significant limitations of it?
    TIA.

    Most 10g databases run fine with automatic stats gathering and this works well 99% of the time.
    If you have very specific performance requirements (e.g stock brokers can be fined if transactions don't complete in a certain time) then you cannot afford to have plans change just because the stats changed from an automated dbms_stats job that is not documented or 100% predictable. For these systems DBAs are generally very nervous of any change, and often lock the table stats, set the outline, or disable automatic stats and write their own job.
    http://www.contractoracle.com

  • 11g automatic stats gathering

    hi *
    would you confirm, please, if 11g doesn't have by default enabled automatic stats gathering as 10g has?
    My 2nd question is then, what is the best way to set such an automatic job to gather stats on a regular basis? If you have any script/code, please share.

    You're right I missed the answer, thanks for your hints.
    I know the consequences of disabling stats.
    But one should know that the default it's not always the best, e.g. open_cursors parameter.
    P.S. Although you gave me the answer I dislike the way you contribute to this thread. You see, you're not my boss, you're not obliged to respond in my thread, so cool down, dear friend. Don't shout with exclamations signs, please.
    Perhaps I have no time to do a deep research and need the solution fast, and I believe this forum is also for that reason.
    So don't question people's questions, as there are always wrong answers, not questions. If you know the answer, just pass it.
    Thanks to all of you,

  • Doubt regarding automatic statistics collection in Oracle 10g

    I am using Oracle 10g in Linux
    Does statistic collection for tables throughout the database happen automatically or should we manually analyze the tables using
    Analyze command or DBMS_STATS package ?
    AWR collects statistics(snapshots) every 1 hr but does it mean it collects only session and database related statistics and not the table related statistics?

    I am using Oracle 10g in Linux Version and os name and version?
    AWR collects statistics(snapshots) every 1 hr butIt's performance related statistics. Read about data gathering and AWR.
    Note that AWR is an extra licensable feature thru Management packs.

  • Statistics gathered during import

    Does after IMP import the tables are analyzed automatically?
    When i done import process of TEST user
    imp system/manager file=/home/oracle/test.dmp FROMUSER=TEST TOUSER=TEST
    and when i execute following query
    SELECT table_name,last_analyzed FROM DBA_TABLES WHERE owner=TEST'
    I find that table/indexes are analyzed automatically.
    Does it means statistics are gathered automatically during import?
    Oracle 10.2.0.1

    Refer to this link please
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/exp_imp.htm#i1020893
    It seems it takes statistics for tables during export
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com

  • Table Statistics Gathering Query

    Hey there,
    I'm currently getting trained in Oracle and one of the questions posed to me were create a table, insert a million rows into it and try to find the number of rows in it. I've tried the following steps to solve this,
    First table creation
    SQL> create table t1(id number);
    Table created.Data insertion
    SQL> insert into t1 select level from dual connect by level < 50000000;
    49999999 rows created.Gathering statistics
    SQL> exec dbms_stats.gather_table_stats('HR','T1');
    PL/SQL procedure successfully completed.Finally counting the number of rows
    SQL> select num_rows from user_tables where table_name='T1';
      NUM_ROWS
      49960410
    SQL> select count(*) from t1;
      COUNT(*)
      49999999My database version is,
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - ProductionI would like to know why there are two different results for the same table when using "num_rows" from the view "user_tables" and the aggregate function "count()" over the same table. Please do keep in mind that i'm studying oracle and this is from a conceptual point of view only. I would like to know how gathering the table statistics works using dbms_stats package works.
    Thank You,
    Vishal

    vishm8 wrote:
    Gathering statistics
    SQL> exec dbms_stats.gather_table_stats('HR','T1');
    PL/SQL procedure successfully completed.I would like to know why there are two different results for the same table when using "num_rows" from the view "user_tables" and the aggregate function "count()" over the same table. Please do keep in mind that i'm studying oracle and this is from a conceptual point of view only. I would like to know how gathering the table statistics works using dbms_stats package works.
    Thank You,
    VishalBecause you aren't specifying a value for estimate_percent in the procedure call (to gather_table_stats) Oracle will pick an estimate value for you. If you want to sample the entire table you would need to explicitly specify that in your procedure call.
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e16760/d_stats.htm#ARPLS68582

Maybe you are looking for

  • Unable to browse the hypertext in the upper part of a website by using Firefox

    I can't browse the hypertext in the upper part of a website by using Firefox. For example, in the website of Firefox, the cursor fails to change from 'arrow' to 'hand' when I point to 'Sign Out' or 'Inbox'. But it's ok for the remaining part of the w

  • Export functions

    I subscribed to Export PDF last week and absolutely cannot access the function when I need it.  While having a PDF file open, when I click on "sign in" on the right side of the screen, nothing happens.  When I check "Export", all I get is the purchas

  • Time Machine doesn't do External HD to External HD Live parallel backups...

    I didn't know where else to post this... I have 12GB of external storage devices attached to my MacBook Pro 17. They are a variety of sizes, and I'm trying to figure out how to use some for storage, and the rest for backing up those storage drives. I

  • How do I backup up my i-phone data?

    Hey, Where do I find my i-phone data on my computer to back it up on a storage drive? I am using a 12" G4 Powerbook laptop with the old silver keys that don't light up running OS 10.4.1. Thanks!

  • Can I import folders from another computers mail?

    I have an iMac with Mountain Lion, and the wife has an older Macbook that won't take Mountain Lion.  She's thinking of giving the Macbook away, but wants to save her mail folders to MY iMac.  Is this kind of import possible.  We do have sharing set u