Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: ANALYZE question

RE: ANALYZE question

From: Smith, Ron L. <rlsmith_at_kmg.com>
Date: Wed, 24 Jul 2002 08:58:59 -0800
Message-ID: <F001.004A107B.20020724085859@fatcity.com>


I looked into the same thing some time ago. I found Oracle papers that recommend using estimate 25% on the tables and a full analyze on the indexes.
I wrote the script below to generate a script with all the analyze statements I needed for the schema to be analyzed. I added date and time displays so I could see how far along I am while the script is processing. I run the output script on a weekly basis.

Ron Smith

set feedback off;
set heading off;
set pagesize 0;
set linesize 120;
set heading off;
set feedback off;
set show off;
spool analyze2.sql

select 'set feedback off;'|| CHR(10) || 'set heading off;' || CHR(10) || 'set pagesize 0;' || 'set linesize 80;'|| CHR(10) | | 'set heading off;' || CHR(10) || 'set feedback off;' || CHR(10) || 'spool analyze_schema2.lst;' from dual
/
select 'select ' || '''' || object_type || ' ' || object_name || '''' ||', to_char(sysdate, ''MM/DD/YYYY HH24:MI'') from dua l;'|| CHR(10) || 'analyze '|| object_type || ' ' || owner || '.' || object_name || ' estimate statistics sample 25 percent f or table;' from dba_objects where object_type in('TABLE') and owner = 'PROD' order by object_type desc
/
select 'select ' || '''' || object_type || ' ' || object_name || '''' ||', to_char(sysdate, ''MM/DD/YYYY HH24:MI'') from dua l;'|| CHR(10) || 'analyze '|| object_type || ' ' || owner || '.' || object_name || ' compute statistics;' from dba_objects w here object_type in('INDEX') and owner = 'PROD' order by object_type desc /

This is what part of the output script looks like:

set feedback off;
set heading off;
set pagesize 0;
set linesize 80;
set heading off;
set feedback off;
spool analyze_schema2.lst;

select 'TABLE DIST', to_char(sysdate, 'MM/DD/YYYY HH24:MI') from dual; analyze TABLE PROD.DIST estimate statistics sample 25 percent for table;

select 'TABLE EXCEPTIONS', to_char(sysdate, 'MM/DD/YYYY HH24:MI') from dual; analyze TABLE PROD.EXCEPTIONS estimate statistics sample 25 percent for table;   

Ron Smith

-----Original Message-----
Sent: Wednesday, July 24, 2002 11:25 AM
To: Multiple recipients of list ORACLE-L

Yechiel

        Consider ANALYZE TABLE ESTIMATE STATISTICS. If you consider sampling theory, with larger tables you shouldn't need to inspect each row. You can vary the number of rows that are sampled. We had a good discussion on this topic on this list awhile back. Dennis Williams
DBA
Lifetouch, Inc.
dwilliams_at_lifetouch.com

-----Original Message-----
Sent: Wednesday, July 24, 2002 9:59 AM
To: Multiple recipients of list ORACLE-L

On the subject on analyzed:
We are doing analyze compute statistics and it takes about an hour. Do you know of ways to speed it up?

Yechiel Adar
Mehish
----- Original Message -----
To: Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com> Sent: Wednesday, July 24, 2002 3:54 PM

> On Wed, Jul 24, 2002 at 04:48:41AM -0800, Boivin, Patrice J wrote:
> > A question:
> >
> > If analyzing SYS objects is a bad idea, why is it included by default in
the
> > analyzing commands (dbms_stats, analyze, dbms_utility.analyze_database)?

>
>

> bug, Doc ID: 203003.996, fixed in 9i...I hate it when that happens.
>
>
>

> >
> > Please correct me if my assumption is wrong, we had strange behaviour
here
> > when SYS objects were analyzed on a development db.
> >
> > Regards,
> > Patrice Boivin
> > Systems Analyst (Oracle Certified DBA)
> >
> > Systems Admin & Operations | Admin. et Exploit. des systèmes
> > Technology Services | Services technologiques
> > Informatics Branch | Direction de l'informatique
> > Maritimes Region, DFO | Région des Maritimes, MPO
> >
> > E-Mail: boivinp_at_mar.dfo-mpo.gc.ca
> >
> >
> > -----Original Message-----
> > Sent: Wednesday, July 24, 2002 9:09 AM
> > To: Multiple recipients of list ORACLE-L
> > Subject: RE: ANALYZE question
> >
> > DBMS_STATS can be used to analyze tables.
> >
> > Dave
> >
> > -----Original Message-----
> > Sent: Wednesday, July 24, 2002 4:03 AM
> > To: Multiple recipients of list ORACLE-L
> >
> >
> > Apart from explicity running an ANALYZE command against a table, what,
if
> > any, other events/actions can cause an analyze to be run on the table?
> >
> > -------------------------
> > Seán O' Neill
> > Organon (Ireland) Ltd.
> > [subscribed: digest mode]
> > --------------------------------------------------------------------
> > This message, including attached files, may contain confidential
> > information and is intended only for the use by the individual
> > and/or the entity to which it is addressed. Any unauthorized use,
> > dissemination of, or copying of the information contained herein is
> > not allowed and may lead to irreparable harm and damage for which
> > you may be held liable. If you receive this message in error or if
> > it is intended for someone else please notify the sender by
> > returning this e-mail immediately and delete the message.
> > --------------------------------------------------------------------
> > --
> > Please see the official ORACLE-L FAQ: http://www.orafaq.com
> > --
> > Author: O'Neill, Sean
> > INET: Sean.ONeill_at_organon.ie
> >
> > Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> > San Diego, California -- Public Internet access / Mailing Lists
> > --------------------------------------------------------------------
> > To REMOVE yourself from this mailing list, send an E-Mail message
> > to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> > the message BODY, include a line containing: UNSUB ORACLE-L
> > (or the name of mailing list you want to be removed from). You may
> > also send the HELP command for other information (like subscribing).
> > --
> > Please see the official ORACLE-L FAQ: http://www.orafaq.com
> > --
> > Author: Farnsworth, Dave
> > INET: DFarnsworth_at_Ashleyfurniture.com
> >
> > Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> > San Diego, California -- Public Internet access / Mailing Lists
> > --------------------------------------------------------------------
> > To REMOVE yourself from this mailing list, send an E-Mail message
> > to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> > the message BODY, include a line containing: UNSUB ORACLE-L
> > (or the name of mailing list you want to be removed from). You may
> > also send the HELP command for other information (like subscribing).
> > --
> > Please see the official ORACLE-L FAQ: http://www.orafaq.com
> > --
> > Author: Boivin, Patrice J
> > INET: BoivinP_at_mar.dfo-mpo.gc.ca
> >
> > Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> > San Diego, California -- Public Internet access / Mailing Lists
> > --------------------------------------------------------------------
> > To REMOVE yourself from this mailing list, send an E-Mail message
> > to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> > the message BODY, include a line containing: UNSUB ORACLE-L
> > (or the name of mailing list you want to be removed from). You may
> > also send the HELP command for other information (like subscribing).
>

> --
> ===============================================================
> Ray Stell stellr_at_vt.edu (540) 231-4109 KE4TJC 28^D
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: Ray Stell
> INET: stellr_at_cns.vt.edu
>

> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> San Diego, California -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Yechiel Adar
  INET: adar76_at_inter.net.il

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: DENNIS WILLIAMS
  INET: DWILLIAMS_at_LIFETOUCH.COM

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Smith, Ron L.
  INET: rlsmith_at_kmg.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Wed Jul 24 2002 - 11:58:59 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US