Solved

Analyzing tables in a schema?

Posted on 2006-12-01
5
1,236 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:Stephen Lappin
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
grouping on time windows 6 51
Oracle 10g - insert string with special characters 8 56
Can't Access My Database 57 66
ORA-02288: invalid OPEN mode 2 30
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
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…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
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…

773 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