Gather statistics for schema at OEM
Hi,
How do we gather schema statistics thru OEM?
in V10+ once every 24 hours Oracle collects statistics by default job; so you do not need to take additional action
Handle: 785301
Status Level: Newbie
Registered: Jul 29, 2010
Total Posts: 36
Total Questions: 17 (17 unresolved)
so many questions without ANY answers.
http://forums.oracle.com/forums/ann.jspa?annID=718
Edited by: sb92075 on Dec 10, 2010 10:12 AM
Similar Messages
-
Exporting and Importing Statistics for Schema objects.
Hello All,
I am trying to gather stats for optimization using, gather_schema_stats for all objects under schema. The manual what i am reading says it covers both Tables and Indexes and we can also include the all partions too. For the safety reasons i was informed by a friend that we should take a back up of old stats into a table (user defined), so as in case of messing up with new stats for performance issue we can use it as an backup copy. So, i have created a user table and exported the stats from existing schema. My Question is, do i have to create one for the indexes too. Or its all in one table. I hope my question is clear.
Generally manuals don't teach all this kind of stuff until unless we learn it by ourselves by trial and error Or getting solutions from great resolvers like you people.
Hope to hear soon.
Thanks in Advance.One table for table and indexes stats is enough, a little test for you :
SCOTT@demo102> exec DBMS_STATS.CREATE_STAT_TABLE('SCOTT','MYTBL');
PL/SQL procedure successfully completed.
SCOTT@demo102> desc mytbl
Name Null? Type
STATID VARCHAR2(30)
TYPE CHAR(1)
VERSION NUMBER
FLAGS NUMBER
C1 VARCHAR2(30)
C2 VARCHAR2(30)
C3 VARCHAR2(30)
C4 VARCHAR2(30)
C5 VARCHAR2(30)
N1 NUMBER
N2 NUMBER
N3 NUMBER
N4 NUMBER
N5 NUMBER
N6 NUMBER
N7 NUMBER
N8 NUMBER
N9 NUMBER
N10 NUMBER
N11 NUMBER
N12 NUMBER
D1 DATE
R1 RAW(32)
R2 RAW(32)
CH1 VARCHAR2(1000)
SCOTT@demo102> create table mytable_obj as select * from all_objects;
Table created.
SCOTT@demo102> create index myindex on mytable_obj(object_id);
Index created.
SCOTT@demo102> exec dbms_stats.gather_table_stats(ownname=>'SCOTT',tabname=>'MYTABLE_OBJ',cascade=>true);
PL/SQL procedure successfully completed.
SCOTT@demo102> select last_analyzed from all_tables where table_name='MYTABLE_OBJ';
07/06/06
SCOTT@demo102> select last_analyzed from all_indexes where table_name='MYTABLE_OBJ';
07/06/06
SCOTT@demo102> exec dbms_stats.export_table_stats('SCOTT','MYTABLE_OBJ',stattab=>'MYTBL')
PL/SQL procedure successfully completed.
SCOTT@demo102> exec dbms_stats.delete_table_stats('SCOTT','MYTABLE_OBJ');
PL/SQL procedure successfully completed.
SCOTT@demo102> select last_analyzed from all_tables where table_name='MYTABLE_OBJ';
-->No value
SCOTT@demo102> select last_analyzed from all_indexes where table_name='MYTABLE_OBJ';
-->No value
SCOTT@demo102> exec dbms_stats.import_table_stats('SCOTT','MYTABLE_OBJ',stattab=>'MYTBL');
PL/SQL procedure successfully completed.
SCOTT@demo102> select last_analyzed from all_tables where table_name='MYTABLE_OBJ';
07/06/06
SCOTT@demo102> select last_analyzed from all_indexes where table_name='MYTABLE_OBJ';
07/06/06
SCOTT@demo102> Nicolas. -
How to reduce time for gather statistics for a table.
I have a table size 520 gb
Its one of the partition size is 38 gb
and total indexes of related table is 412 gb.
Server/instance details.
==========
56 cpu -> Hyper threading enable
280 gb ram
35 gb sga
27 gb buffer cache
4.5 gb shared pool size
25 gb pga
undo size 90gb
temp size 150 gb
Details :
exec dbms_stats.gather_table_stats('OWNER','TAB_NAME',PARTNAME=>'PART_NAME',CASCADE=>FALSE,ESTIMATE_PERCENT=>10,DEGREE=>30,NO_INVALIDATE=>TRUE);
when i am firing this in an ideal time when there is no load that time also is is taking 28 mins to complete.
Can anybody please reply me how can we reduce the stats gather time.
Thanks in advance,
Tapas Karmakar
Oracle DBA.Enable tracing to see where the time is going.
parallel 30 seems optimistic - unless you have a large number of discs to support the I/O ?
you haven't limited histogram collection, and most of the time spent of histograms may be wasted time - what histograms do you really need, and how many does Oracle analyse for and then discard ?
Using a block sample may help slightly
You haven't limited the granularity of the stats collection to the partition - the default is partition plus table, so I think you're also doing a massive sample on the table after completing the partition. Is this what you want to do, or do you have an alternative strategy for generating table-level stats.
Regards
Jonathan Lewis -
How I gather statistics via OEM db control?
Hi,
According to the documentation,
I may setup a job to automatically
gather statistics for all the segments in my database
via EM database control.
I cant find any documentation on how to do this.
I did find a link in EM which will allow me
to gather statistics ad hoc but I want it automated.
Thanks,
-moiThere should be a stats gathering program scheduled
by default. Check under Database > Administration >
Scheduler > Jobs in Database Control. The job is called
SYS.GATHER_STATS_JOB. You will need to login as SYS to
see the job. The job runs the
DBMS_STATS.GATHER_DATABASE_STATS_JOB_PROC procedure.
You can, of course, schedule any other
DBMS_STATS.GATHER_* procedures if you prefer.
Hope this helps.
Kailash. -
exec dbms_stats.gather_schema_stats( -
ownname => 'PROD1, -
options => 'GATHER AUTO', -
estimate_percent => dbms_stats.auto_sample_size, -
method_opt => 'for all columns size repeat', -
degree => 25 -
I have 400 tables in PROD1 schema, but I want to gather statistics for 120 tables only
How to gathere statistics for 120 tables ?
For specifying degree, what is the minimum and maximum? Will this affect any performanceuser8934564 wrote:
exec dbms_stats.gather_schema_stats( -
ownname => 'PROD1, -
options => 'GATHER AUTO', -
estimate_percent => dbms_stats.auto_sample_size, -
method_opt => 'for all columns size repeat', -
degree => 25 -
I have 400 tables in PROD1 schema, but I want to gather statistics for 120 tables only
How to gathere statistics for 120 tables ?
For specifying degree, what is the minimum and maximum? Will this affect any performanceFrom Oracle Docs:
Degree is Degree of parallelism. The default for degree is NULL. The default value can be changed using the SET_PARAM Procedure. NULL means use the table default value specified by the DEGREE clause in the CREATE TABLE or ALTER TABLE statement. Use the constant DBMS_STATS.DEFAULT_DEGREE to specify the default value based on the initialization parameters. The AUTO_DEGREE value determines the degree of parallelism automatically. This is either 1 (serial execution) or DEFAULT_DEGREE (the system default value based on number of CPUs and initialization parameters) according to size of the object.To be able to gather stats for 120 tables:
1) You can create a temporary table, enter the names of these tables, create a PL/SQL procedure, loop for the table names and call GATHER_TABLE_STATS for each table.
2) You can lock other table's stats, and call GATHER_SCHEMA_STATS.
Regards
Gokhan -
About gather statistics - ANALYZE on Oracle views
Oracle® Database Reference
11g Release 1 (11.1)
Part Number B28320-01
ALL_TABLES describes the relational tables accessible to the current user. To gather statistics for this view, use the ANALYZE SQL statement.
Columns marked with an asterisk (*) are populated only if you collect statistics on the table with the ANALYZE statement or the DBMS_STATS package
I thought ANALYZE command shouldn't be used to gather stats, as it explained as well on the ANALYZE command description.
Furthermore, explanations on how the columns should be populated are not clear enough. Maybe my english level is too low, but it seems we have to run any thing on the view itself.
Same for ALL_INDEXES.
Nicolas.Hi Nicolas. You're right that we recommend using DBMS_STATS for most statistics-gathering purposes. I'll pass this along to the writer who manages the Database Reference, to see that it gets updated. I'll also ask him to check the clarity of the column descriptions.
Regards,
Diana -
Skip gather stats for a partition | table from the gather_stats_job in 10g
Hi all,
Can we skip gather statistics for a table or a partition in a partitioned-table from the GATHER_STATS_JOB in Oracle 10g ?
(cause that partition store in an offline-datafile, so GATHER_STATS_JOB had errors when running in sheduled).
Thanks.
Edited by: user8710247 on Nov 26, 2011 6:41 PMGATHER_TABLE_STATS will default to GRANULARITY 'AUTO' which will include Global and Partition Statistics. Global Statistics have to be across all the Partitions -- so Oracle will attempt to read all the partitions for this !
You need to run GATHER_TABLE_STATS with GRANULARITY 'PARTITION' and naming the other Partitions --- i.e. run it for each of the online partitions.
See :
SQL> create table XYZ (col_1 number, col_2 varchar2(5))
2 partition by range (col_1)
3 (partition P1 values less than (10) tablespace HEMANT,
4 partition P2 values less than (100) tablespace USERS)
5 /
Table created.
SQL> insert into XYZ values (5,'Five');
1 row created.
SQL> insert into XYZ values (50,'Fifty');
1 row created.
SQL> exec dbms_stats.gather_table_stats('','XYZ',estimate_percent=>100,granularity=>'ALL');
PL/SQL procedure successfully completed.
SQL> select partition_name, tablespace_name , num_rows, sample_size from user_tab_partitions
2 where table_name = 'XYZ'
3 /
PARTITION_NAME TABLESPACE_NAME NUM_ROWS
SAMPLE_SIZE
P1 HEMANT 1
1
P2 USERS 1
1
SQL>
SQL> exec dbms_stats.lock_table_stats('','XYZ');
PL/SQL procedure successfully completed.
SQL> alter tablespace HEMANT offline;
Tablespace altered.
SQL> exec dbms_stats.gather_table_stats('','XYZ',estimate_percent=>100,granularity=>'ALL');
BEGIN dbms_stats.gather_table_stats('','XYZ',estimate_percent=>100,granularity=>'ALL'); END;
ERROR at line 1:
ORA-20005: object statistics are locked (stattype = ALL)
ORA-06512: at "SYS.DBMS_STATS", line 13159
ORA-06512: at "SYS.DBMS_STATS", line 13179
ORA-06512: at line 1
SQL>
SQL> exec dbms_stats.unlock_table_stats('','XYZ');
PL/SQL procedure successfully completed.
SQL> exec dbms_stats.lock_partition_stats('','XYZ','P1');
PL/SQL procedure successfully completed.
SQL> exec dbms_stats.gather_table_stats('','XYZ',estimate_percent=>100,granularity=>'ALL');
BEGIN dbms_stats.gather_table_stats('','XYZ',estimate_percent=>100,granularity=>'ALL'); END;
ERROR at line 1:
ORA-00376: file 2 cannot be read at this time
ORA-01110: data file 2:
'/usr/oracle/oradata/MONDB/datafile/o1_mf_hemant_7d6m8zkx_.dbf'
ORA-06512: at "SYS.DBMS_STATS", line 13159
ORA-06512: at "SYS.DBMS_STATS", line 13179
ORA-06512: at line 1
SQL>
SQL> exec dbms_stats.gather_table_stats('','XYZ',estimate_percent=>100,partname=>'P2');
BEGIN dbms_stats.gather_table_stats('','XYZ',estimate_percent=>100,partname=>'P2'); END;
ERROR at line 1:
ORA-00376: file 2 cannot be read at this time
ORA-01110: data file 2:
'/usr/oracle/oradata/MONDB/datafile/o1_mf_hemant_7d6m8zkx_.dbf'
ORA-06512: at "SYS.DBMS_STATS", line 13159
ORA-06512: at "SYS.DBMS_STATS", line 13179
ORA-06512: at line 1
SQL> exec dbms_stats.gather_table_stats('','XYZ',estimate_percent=>100,partname=>'P2',granularity=>'GLOBAL AND PARTITION');
BEGIN dbms_stats.gather_table_stats('','XYZ',estimate_percent=>100,partname=>'P2',granularity=>'GLOBAL AND PARTITION'); END;
ERROR at line 1:
ORA-00376: file 2 cannot be read at this time
ORA-01110: data file 2:
'/usr/oracle/oradata/MONDB/datafile/o1_mf_hemant_7d6m8zkx_.dbf'
ORA-06512: at "SYS.DBMS_STATS", line 13159
ORA-06512: at "SYS.DBMS_STATS", line 13179
ORA-06512: at line 1
SQL>
SQL> exec dbms_stats.gather_table_stats('','XYZ',estimate_percent=>100,partname=>'P2',granularity=>'PARTITION');
PL/SQL procedure successfully completed.
SQL>Hemant K Chitale -
Gather statistics or analyze table
What is the difference between gather statistics for table and analyze table?
Regards
ArpitAnalyzing a table is gathering statistics (whether you're using the old ANALYZE statement or the preferred dbms_stats package).
-
Exclude Schema from Gather Statistics Job
I am using 11.1.0,7. I would like to know if we can exclude some schemas While Oracle automatically gathers the statistics.
Reason I want this is that, I have one database that supports multiple applications but as per one application's demand we should not be gathering stats on it's schema. So, in totality I have 20 Schemas but while this jobs run, I want to exclude 2 schemas that this application supports.
Locking the Stats for these schemas is not an option.
Thanks!Have you enquired from the vendor exactly why they do not want you to gather statistics on it's schema?
Is there other options they are willing to consider like baselining the explain plan or perhaps not publishing the statistics to the tables...using the pending statistics feature?
Exec dbms_stats.set_table_prefs('SH', 'CUSTOMERS', 'PUBLISH', 'false');
Regards
Tim Boles
Edited by: Tim Boles on Aug 4, 2010 11:11 AM -
Hi,
I launched a job to gather statistics on just one schema on my DATABASE in OEM. How can I identify it's session ? Many thanks before.You can try below query:
select s.username, s.sid,s.serial#, sql.sql_Text
from v$session s, v$sqlarea sql
where s.sql_address = sql.address and s.sql_hash_value = sql.hash_value and
s.username = '&username' and lower(sql.sql_text) like '%dbms_stats%'
Best Regards
Krystian Zieja / mob -
Suggested schedule for gather statistics on sysadm
We have recently upgraded to 11.1.0.7 with psoft version 9.0 and tools 8.49 on sun solaris version 10. Currently we are running stats every night on all non work sysadm tables. I'm wondering if this is too much. We are seeing sql statements use different explain plans. For ex: one sql takes plan A and finishes in expected time. At some other point during the week that same sql will take plan B and will either never finish or take way too long.
So I'm curious to see how other folks are handling their statistics.
Other items of note:
we disabled the nightly oracle statistics job
our database is about 200 GB of used space
In any feedback is much appreciated.Welcome to the forum!
Whenever you post provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION)
>
For example there is a table T1 with 25GB size (3 crores rows) and partitioned when i try generating statistics for a T1 table with below command it takes lots of time and i dont know what is the progress.
>
Your command will generate statistics for the entire table; that is, ALL partitions. Is that what you intended?
Sometimes partitioned tables have historical data in older partitions and a small number of ACTIVE partitions where the amount of data changes substantially. You could collect stats only on the partitions that have large data changes. The older, static partitions may not need frequent stat collections since the amount of data that changes is small.
If you are using 11g you could collect incremental statistics instead of global stats. Here is an article by Maria Colgan, an Oracle developer on the Optimizer team on stats.
https://blogs.oracle.com/optimizer/entry/how_do_i_compare_statistics -
Hi folks!
I gathered statistcs in one schema with folowing options:
exec dbms_stats.gather_schema_stats(user,method_opt=>'FOR ALL COLUMNS SIZE 1',estimate_percent=>null,gather_temp=>false,cascade=>true,degree=>dbms_stats.auto_degree);Then:
exec dbms_stats.gather_schema_stats(user,method_opt=>'FOR ALL COLUMNS SIZE SKEWONLY',estimate_percent=>null,gather_temp=>false,cascade=>true,degree=>dbms_stats.auto_degree);Now, I turn on table monitoring and suggest to gather statistics (per day) with that parameters:
dbms_stats.gather_schema_stats(ownname =>user, options=>'GATHER STALE', gather_temp => false, cascade => true, estimate_percent => 100, degree => dbms_stats.auto_degree);Default method_opt is FOR ALL COLUMNS SIZE AUTO.
Now I got better perfomance. How often I need to gather statstics?
Thanks in advance.
Best regards, Pavel.Thanks, I also think so.
Little test-case:
SQL>exec dbms_stats.gather_table_stats(user,'TABLE1',estimate_percent=>null);
Elapsed: 00:00:01.03
SQL> select column_name,num_distinct,sample_size from user_tab_col_statistics where table_name='TABLE1;
COLUMN_NAME NUM_DISTINCT SAMPLE_SIZE
DISGRP 7944 33204
DISMBR 18948 33204
TYPE 4 33204
Elapsed: 00:00:00.03
SQL> exec dbms_stats.gather_table_stats(user,'TABLE1',estimate_percent=>10);
PL/SQL procedure successfully completed.
Elapsed: 00:00:01.78
SQL> select column_name,num_distinct,sample_size from user_tab_col_statistics where table_name='TABLE1';
COLUMN_NAME NUM_DISTINCT SAMPLE_SIZE
DISGRP 3836 3269
DISMBR 13686 3269
TYPE 4 3269
Elapsed: 00:00:00.00
SQL> exec dbms_stats.gather_table_stats(user,'TABLE1',estimate_percent=>100);
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.52
SQL> select column_name,num_distinct,sample_size from user_tab_col_statistics where table_name='TABLE1';
COLUMN_NAME NUM_DISTINCT SAMPLE_SIZE
DISGRP 7944 33204
DISMBR 18948 33204
TYPE 4 33204
Elapsed: 00:00:00.01
SQL> exec dbms_stats.gather_table_stats(user,'TABLE1',estimate_percent=>dbms_stats.auto_sample_size);
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.53
SQL> select column_name,num_distinct,sample_size from user_tab_col_statistics where table_name='TABLE1';
COLUMN_NAME NUM_DISTINCT SAMPLE_SIZE
DISGRP 8448 5568
DISMBR 18948 33204
TYPE 4 5568
Elapsed: 00:00:00.00
SQL> select count(distinct disgrp) from TABLE1;
COUNT(DISTINCTDISGRP)
7944
Elapsed: 00:00:00.02
SQL> select count(distinct dismbr) from TABLE1;
COUNT(DISTINCTDISMBR)
18948
Elapsed: 00:00:00.03
SQL> select count(distinct type) from TABLE1;
COUNT(DISTINCTTYPE)
4
Elapsed: 00:00:00.01
SQL> select column_name,num_distinct,sample_size from user_tab_col_statistics where table_name='TABLE2';
COLUMN_NAME NUM_DISTINCT SAMPLE_SIZE
ID 219120 219120
UNIT 114762 219120
LOC 61 219120
TIS 1230 219120
RTYP 3 219120
Elapsed: 00:00:00.02
SQL> exec dbms_stats.gather_table_stats(user,'TABLE2',estimate_percent=>null);
PL/SQL procedure successfully completed.
Elapsed: 00:00:07.61
SQL> select column_name,num_distinct,sample_size from user_tab_col_statistics where table_name='TABLE2';
COLUMN_NAME NUM_DISTINCT SAMPLE_SIZE
ID 219120 219120
UNIT 114762 219120
LOC 61 219120
TIS 1230 219120
RTYP 3 219120
Elapsed: 00:00:00.00
SQL> exec dbms_stats.gather_table_stats(user,'TABLE2',estimate_percent=>10);
PL/SQL procedure successfully completed.
Elapsed: 00:00:02.90
SQL> select column_name,num_distinct,sample_size from user_tab_col_statistics where table_name='TABLE2';
COLUMN_NAME NUM_DISTINCT SAMPLE_SIZE
ID 219950 21995
UNIT 70812 21995
LOC 43 21995
TIS 496 21995
RTYP 3 21995
Elapsed: 00:00:00.00
SQL> exec dbms_stats.gather_table_stats(user,'TABLE2',estimate_percent=>50);
PL/SQL procedure successfully completed.
Elapsed: 00:00:03.70
SQL> select column_name,num_distinct,sample_size from user_tab_col_statistics where table_name='TABLE2';
COLUMN_NAME NUM_DISTINCT SAMPLE_SIZE
ID 218716 109358
UNIT 92338 109426
LOC 61 109455
TIS 994 109567
RTYP 3 109422
Elapsed: 00:00:00.00
SQL> exec dbms_stats.gather_table_stats(user,'COMPS',estimate_percent=>100);
PL/SQL procedure successfully completed.
Elapsed: 00:00:04.37
SQL> select column_name,num_distinct,sample_size from user_tab_col_statistics where table_name='TABLE2';
COLUMN_NAME NUM_DISTINCT SAMPLE_SIZE
ID 219120 219120
UNIT 114762 219120
LOC 61 219120
TIS 1230 219120
RTYP 3 219120
Elapsed: 00:00:00.00
SQL> exec dbms_stats.gather_table_stats(user,'COMPS',estimate_percent=>dbms_stats.auto_sample_size);
PL/SQL procedure successfully completed.
Elapsed: 00:00:03.81
SQL> select column_name,num_distinct,sample_size from user_tab_col_statistics where table_name='TABLE2';
COLUMN_NAME NUM_DISTINCT SAMPLE_SIZE
ID 217968 54492
UNIT 122237 54492
LOC 31 5495
TIS 240 5495
RTYP 3 5495
Elapsed: 00:00:00.01
SQL> select count(distinct id) from TABLE2;
COUNT(DISTINCTID)
219120
Elapsed: 00:00:00.27
SQL> select count(distinct unit) from TABLE2;
COUNT(DISTINCTUNIT)
114762
Elapsed: 00:00:00.30
SQL> select count(distinct loc) from TABLE2;
COUNT(DISTINCTLOC)
61
Elapsed: 00:00:00.06
SQL> select count(distinct tis) from TABLE2;
COUNT(DISTINCTTIS)
1230
Elapsed: 00:00:00.09In that situation, auto_sample_size not bad? But estimate_percent=>100 - exact.
Best regards, Pavel. -
Gather Statistics recommendations
Hi
How to find the recommendations from gather schema statistics job?
Thanks998932 wrote:
Sometimes when a Gather Schema stats job is scheduled(parameters:APPLSYS, 30, , NOBACKUP, , LASTRUN, GATHER, , Y), it will get executed in 25 minutes and sometimes 60 minutes.
a) What could be the possible reasons?This is normal and it depends to how busy your system is.
b) How can I reduce the execution time?How big is your database and how long it takes to gather stats for all schemes?
What if you change 30 to 10, does it make a difference?
c) What If I increase the estimate percent and give the Degree values?
PROD CPU's are 12, cores are 6 and RAM is 72 GBYou need to try it yourself and see how long it takes. Increasing the estimate percent will take longer but with different degree value this might make it different. You should tweak your parameters to find the best values and your concern should be about your system performance after running gather schematic stats instead of how long the program takes to run.
Thanks,
Hussein -
Scheduled Job to gather stats for multiple tables - Oracle 11.2.0.1.0
Hi,
My Oracle DB Version is:
BANNER Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
In our application, we have users uploading files resulting in insert of records into a table. file could contain records ranging from 10000 to 1 million records.
I have written a procedure to bulk insert these records into this table using limit clause. After the insert, i noticed my queries run slow against these tables if huge files are uploaded simultaneously. After gathering stats, the cost reduces and the queries executed faster.
We have 2 such tables which grow based on user file uploads. I would like to schedule a job to gather stats during a non peak hour apart from the nightly automated oracle job for these two tables.
Is there a better way to do this?
I plan to execute the below procedure as a scheduled job using DBMS_SCHEDULER.
--Procedure
create or replace
PROCEDURE p_manual_gather_table_stats AS
TYPE ttab
IS
TABLE OF VARCHAR2(30) INDEX BY PLS_INTEGER;
ltab ttab;
BEGIN
ltab(1) := 'TAB1';
ltab(2) := 'TAB2';
FOR i IN ltab.first .. ltab.last
LOOP
dbms_stats.gather_table_stats(ownname => USER, tabname => ltab(i) , estimate_percent => dbms_stats.auto_sample_size,
method_opt => 'for all indexed columns size auto', degree =>
dbms_stats.auto_degree ,CASCADE => TRUE );
END LOOP;
END p_manual_gather_table_stats;
--Scheduled Job
BEGIN
-- Job defined entirely by the CREATE JOB procedure.
DBMS_SCHEDULER.create_job ( job_name => 'MANUAL_GATHER_TABLE_STATS',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN p_manual_gather_table_stats; END;',
start_date => SYSTIMESTAMP,
repeat_interval => 'FREQ=DAILY; BYHOUR=12;BYMINUTE=45;BYSECOND=0',
end_date => NULL,
enabled => TRUE,
comments => 'Job to manually gather stats for tables: TAB1,TAB2. Runs at 12:45 Daily.');
END;Thanks,
SomiyaThe question was, is there a better way, and you partly answered it.
Somiya, you have to be sure the queries have appropriate statistics when the queries are being run. In addition, if the queries are being run while data is being loaded, that is going to slow things down regardless, for several possible reasons, such as resource contention, inappropriate statistics, and having to maintain a read consistent view for each query.
The default collection job decides for each table based on changes it perceives in the data. You probably don't want the default collection job to deal with those tables. You probably do want to do what Dan suggested with the statistics. But it's hard to tell from your description. Is the data volume and distribution volatile? You surely want representative statistics available when each query is started. You may want to use all the plan stability features available to tell the optimizer to do the right thing (see for example http://jonathanlewis.wordpress.com/2011/01/12/fake-baselines/ ). You may want to just give up and use dynamic sampling, I don't know, entire books, blogs and papers have been written on the subject. It's sufficiently advanced technology to appear as magic. -
Disable Statistics for specific Tables
Is it possible to disable statistics for specific tables???
If you want to stop gathering statistics for certain tables, you would simply not call DBMS_STATS.GATHER_TABLE_STATS on those particular tables (I'm assuming that is how you are gathering statistics at the moment). The old statistics will remain around for the CBO, but they won't be updated. Is that really what you want?
If you are currently using GATHER_SCHEMA_STATS to gather statistics, you would have to convert to calling GATHER_TABLE_STATS on each table. You'll probably want to have a table set up that lists what tables to exclude and use that in the procedure that calls GATHER_TABLE_STATS.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC
Maybe you are looking for
-
I was having some problems syncing my Tungsten T5 following editing/deleting some programs. Then I got a new computer. When I got the new computer, the help desk suggested I manually enter the data from the Palm into the newly installed Palm progra
-
Bought a P67A-GD65 on Saturday? How do I get the free 3Dmark 11?
3Dmark 11 is advertised on this site with any purchase of a P67 board on the main site. I bought the board this weekend, but there is no voucher in the box with code to unlock the full edition. Can someone from MSI direct me to the proper channels fo
-
My Iphone stolen Is it possible to disable it by serial number
my Iphone stolen Is it possible to disable it by serial number or Appl co?
-
I've had this same problem going on for about 6 months now. My ZEN vision M 30gig is stuck in Recovery Mode with the 4 options. I've tried every single guide there is. WMP is not installed. Nothing from creative is installed. I've tried downloading t
-
How to record with en external mic instead of built-in in iSight
Hi, I just want to record simple videos with the webb cam iSight. I want the audio to sound better and use an external mic during the recording. After testing I see that iMove uses only the built-in mic, there is no difference if I connect the extern