Solved

Analyzing tables in a schema?

Posted on 2006-12-01
5
1,234 Views
Last Modified: 2013-12-11
I want to analyze some tables in a schema that have not been analyzed in a few days. What is the quickest non time consuming method or command to analyze tables in a schema without consuming alot time waiting on this analyze procedure to finish?
0
Comment
Question by:Omega002
5 Comments
 

Author Comment

by:Omega002
ID: 18053991
FYI Oracle database for this situation is Oracle 9i.
0
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 18055342
you can analyze all the tables in a schema by using dbms_stats package. Use the procedure/function which is appropriate for you.

But in case there are only 3 tables/indexes ( assuming total objects can be 100 in your schema including your indexes as well ) in the last 2 days which are not analyzed, then doing it manually will be the fast way.

Thanks

0
 
LVL 27

Accepted Solution

by:
sujith80 earned 250 total points
ID: 18068614
"quickest non time consuming method "
I dont think that you can save the time for analyzing a table using any method. Oracle will take the time it needs to analyze the table.

-- You can go for estimating the statistics rather than computing the statistics. Which will take a sample of data and arrive at the statistics. The syntax goes like "analyze table x estimate statistics" (You should be aware of this as you have a periodic routine to analyze tables.) But this statistics wont be as accurate as "analyze table x compute statistics".

-- if your tables are partitioned, analyze only the partition that contains the recent data. like:
analyze table x partition(px) compute statistics
0
 
LVL 18

Expert Comment

by:rbrooker
ID: 18071564
Hi,

sujith80's answer is right, but "analyze table..." is not as recommended as using the dbms_stats package.

you can try :
dbms_stats.gather_schema_stats('SCHEMA_NAME',
    estimate_percent=>10,  -- analyze based on 10% of table
    block_sample=>TRUE,  -- use block sampling, not row sampling
    CASCADE=>TRUE,   -- include indexes
    method_opt=> 'FOR ALL COLUMNS SIZE AUTO',  -- can specify which columns to analyze, do all of them
    options=> 'GATHER EMPTY');  -- empty stats only

dbms_stats.gather_schema_stats('SCHEMA_NAME',
    estimate_percent=>10,
    block_sample=>TRUE,
    CASCADE=>TRUE,
    method_opt=> 'FOR ALL COLUMNS SIZE AUTO',
    options=> 'GATHER STALE');  -- stale stats only

this will gather stats for tables that do not have any, and for tables which have had over 10% of changes since the last time the stats were gathered...

good luck :)
0
 
LVL 7

Expert Comment

by:lappins
ID: 18075949
You can write an Oracle job to gather stats (in the background). This example analyses all tables overnight on Sunday.


DECLARE
  X NUMBER;
BEGIN
  SYS.DBMS_JOB.SUBMIT
    ( job       => X
     ,what      => 'DBMS_STATS.GATHER_SCHEMA_STATS (ownname => ''SCHEMA_NAME'', estimate_percent =>100,granularity=>''ALL'',cascade=>TRUE);'
     ,next_date => to_date('10/12/2006 00:00:00','dd/mm/yyyy hh24:mi:ss')
     ,interval  => 'NEXT_DAY(TRUNC(SYSDATE), ''SUNDAY'')'
     ,no_parse  => TRUE
    );
  SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));
END;
/

commit;
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now