DBAsupport.com Forums - Powered by vBulletin
Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: DBMS_STATS options

Hybrid View

  1. #1
    Join Date
    Jan 2001
    Posts
    3,134

    DBMS_STATS options

    Howdy all you politically correct boys and girls;

    Is there any way to run dbms_stats at the schema level and omit a few HUGE partitioned tables.

    What we have now is a script that analyzes all of the tables for this schema, this works fine BUT.. we are adding another 40 or so tables to this schema and now have to keep updating this script.

    Essentially we would like to avoid this and just have the flexability to analyze the monster tables at other times.

    I do not see any options online, a simple WHERE clause would work if it existed.


    HP/UX 11
    Oracle 9.2.0.6
    I remember when this place was cool.

  2. #2
    Join Date
    Sep 2002
    Location
    England
    Posts
    7,334
    i dont think there is an exceptions kinda thing, but you can do a little loop to select the table name from user_tables with a where clause then pass the table name to dbms_stats

  3. #3
    Join Date
    Jan 2001
    Posts
    3,134
    Thanks dave,
    I can generate it through SQL plus that way, but it is a bit tedious.
    I remember when this place was cool.

  4. #4
    Join Date
    Jan 2002
    Location
    NC, USA
    Posts
    24
    ho rm analyze.tmp.sql
    spool analyze.tmp.sql
    set heading off
    select 'prompt >processing: '
    ||table_name
    ||chr(13)
    ||'select to_char(sysdate,''MM/DD/YY HH24:MI:SS'') from dual;'
    ||chr(13)
    ||'execute dbms_stats.gather_table_stats(ownname => user, tabname => '''||table_name||''', degree => 4, cascade => true);'
    ||chr(13)
    ||'select to_char(sysdate,''MM/DD/YY HH24:MI:SS'') from dual;' from user_tables where table_name<>'BIG_TABLE';
    spool off
    @analyze.tmp.sql
    ho rm analyze.tmp.sql
    OCP DBA 8, 8i, 9i, 10g

  5. #5
    Join Date
    Jan 2001
    Posts
    3,134
    Quote Originally Posted by danromeo
    ho rm analyze.tmp.sql
    spool analyze.tmp.sql
    set heading off
    select 'prompt >processing: '
    ||table_name
    ||chr(13)
    ||'select to_char(sysdate,''MM/DD/YY HH24:MI:SS'') from dual;'
    ||chr(13)
    ||'execute dbms_stats.gather_table_stats(ownname => user, tabname => '''||table_name||''', degree => 4, cascade => true);'
    ||chr(13)
    ||'select to_char(sysdate,''MM/DD/YY HH24:MI:SS'') from dual;' from user_tables where table_name<>'BIG_TABLE';
    spool off
    @analyze.tmp.sql
    ho rm analyze.tmp.sql
    HUH?

    SQL no worky
    I remember when this place was cool.

  6. #6
    Join Date
    Jan 2002
    Location
    NC, USA
    Posts
    24
    are you running on windows?

    if yes you need to change rm with del

    you need to create a sql file with that content (an.sql)

    then execute that script:

    sqlplus user/pass@host @an.sql
    Last edited by danromeo; 06-29-2005 at 04:24 PM.
    OCP DBA 8, 8i, 9i, 10g

  7. #7
    Join Date
    Jan 2001
    Posts
    3,134
    Quote Originally Posted by danromeo
    are you running on windows?
    I tried it in both environments.
    I also tried just the SQL in SQL plus.
    Did you get it to run?
    I remember when this place was cool.

  8. #8
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    I just rewrote my entire statistics gathering process. Basically what I do in this case is I have a table of owner/tablenames that want to exclude from analyzing. I use dbms_stats.gather_database_stats(options=>'LIST STALE') to get a list of objects to analyze. I then bounce those against my table that stores the objects I want to exclude to decide if I need to analyze the table.

    You can read about my basic algorithm at http://marist89.blogspot.com/2005/06...sstats_14.html.
    Jeff Hunter

  9. #9
    Join Date
    May 2005
    Location
    AZ, USA
    Posts
    131
    Quote Originally Posted by marist89
    You can read about my basic algorithm at http://marist89.blogspot.com/2005/06...sstats_14.html.
    Mr. Genius, do you have any tables where you want to generate histograms, I didn't see it mentioned in your blog?
    If so, what criteria are you using to determine the need for the histograms.
    Thanks.

  10. #10
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    Quote Originally Posted by dbtoo
    Mr. Genius, do you have any tables where you want to generate histograms, I didn't see it mentioned in your blog?
    If so, what criteria are you using to determine the need for the histograms.
    Thanks.
    Histograms are a special case. Most times, you know what tables need histograms and how many buckets. Same deal, if the table/index reports as stale, you bounce it off a table of know tables that need histograms.
    Jeff Hunter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width