RE: how to keep statistics up to date for CBO
Bob, I do the following: First, alter all tables turning monitoring on: alter table {table name} monitoring; Monitoring says: Specify MONITORING if you want Oracle to collect modification statistics on table. These statistics are estimates of the number of rows affected by DML statements over a particular period of time. They are available for use by the optimizer or for analysis by the user. Then use the following. It recalculates stats for those tables that have been changed enough to warrant stats. The User_Tab_Modifications table will hold a record if 10% of the table was changed. I've been using this for a while now, and it seems to be working fine. As you can see, I have a database table that I insert a record into so I can see how much work is done. I'm happy with it. And I'm not gathering stats for tables that I don't need to. I run this job daily. Hope this helps. PROCEDURE WTWDBA.Wtw_Gather_Statistics IS /* Procedure Name : Wtw_Gather_Statistics Author : Tom Mercadante Mercadante Systems Design June 14, 2001 Purpose: This Package will use the System DBMS_STATS package to gather statistics for both tables and indexes. */ loc_table_name USER_TABLES.TABLE_NAME%TYPE; loc_index_name USER_INDEXES.INDEX_NAME%TYPE; tbl_count NUMBER := 0; indx_count NUMBER := 0; loc_start_time DATE; CURSOR c1 IS SELECT ut.table_name FROM USER_TABLES UT, USER_TAB_MODIFICATIONS UTM WHERE UT.TABLE_NAME = UTM.table_name; CURSOR c2 IS SELECT index_name FROM USER_INDEXES WHERE table_name = loc_table_name; BEGIN loc_start_time := SYSDATE; -- Gather statistics on tables OPEN c1; LOOP FETCH c1 INTO loc_table_name; EXIT WHEN c1%NOTFOUND; dbms_stats.gather_table_stats('WTWDBA',loc_table_name); tbl_count := tbl_count + 1; -- Gather statistics on indexes OPEN c2; LOOP FETCH c2 INTO loc_index_name; EXIT WHEN c2%NOTFOUND; dbms_stats.gather_index_stats('WTWDBA',loc_index_name); indx_count := indx_count + 1; END LOOP; CLOSE c2; END LOOP; CLOSE c1; -- insert a record into the job log INSERT INTO WTW_JOB_LOG(JOB_NAME, RUN_DATE, START_TIME, END_TIME, MSG_TXT) VALUES('Wtw_Gather_Statistics',SYSDATE,loc_start_time, SYSDATE,INITCAP('SCHEMA Stats Complete') || CHR(10) || tbl_count || INITCAP(' TABLES Analyzed ') || CHR(10) || indx_count || INITCAP(' INDEXES Analyzed')); COMMIT; END; Tom Mercadante Oracle Certified Professional -Original Message- Sent: Wednesday, October 08, 2003 4:54 PM To: Multiple recipients of list ORACLE-L How does one keep CBO statistics for an applications base tables up to date? We are about to implement the CBO any must read documents. Many thanks bob -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Bob Metelsky INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (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.net -- Author: Mercadante, Thomas F INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (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).
Re: RE: how to keep statistics up to date for CBO
does monitoring have any real overhead in a high transaction system? From: Mercadante, Thomas F [EMAIL PROTECTED] Date: 2003/10/09 Thu AM 08:59:33 EDT To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] Subject: RE: how to keep statistics up to date for CBO Bob, I do the following: First, alter all tables turning monitoring on: alter table {table name} monitoring; Monitoring says: Specify MONITORING if you want Oracle to collect modification statistics on table. These statistics are estimates of the number of rows affected by DML statements over a particular period of time. They are available for use by the optimizer or for analysis by the user. Then use the following. It recalculates stats for those tables that have been changed enough to warrant stats. The User_Tab_Modifications table will hold a record if 10% of the table was changed. I've been using this for a while now, and it seems to be working fine. As you can see, I have a database table that I insert a record into so I can see how much work is done. I'm happy with it. And I'm not gathering stats for tables that I don't need to. I run this job daily. Hope this helps. PROCEDURE WTWDBA.Wtw_Gather_Statistics IS /* Procedure Name : Wtw_Gather_Statistics Author : Tom Mercadante Mercadante Systems Design June 14, 2001 Purpose: This Package will use the System DBMS_STATS package to gather statistics for both tables and indexes. */ loc_table_name USER_TABLES.TABLE_NAME%TYPE; loc_index_name USER_INDEXES.INDEX_NAME%TYPE; tbl_count NUMBER := 0; indx_count NUMBER := 0; loc_start_time DATE; CURSOR c1 IS SELECT ut.table_name FROM USER_TABLES UT, USER_TAB_MODIFICATIONS UTM WHERE UT.TABLE_NAME = UTM.table_name; CURSOR c2 IS SELECT index_name FROM USER_INDEXES WHERE table_name = loc_table_name; BEGIN loc_start_time := SYSDATE; -- Gather statistics on tables OPEN c1; LOOP FETCH c1 INTO loc_table_name; EXIT WHEN c1%NOTFOUND; dbms_stats.gather_table_stats('WTWDBA',loc_table_name); tbl_count := tbl_count + 1; -- Gather statistics on indexes OPEN c2; LOOP FETCH c2 INTO loc_index_name; EXIT WHEN c2%NOTFOUND; dbms_stats.gather_index_stats('WTWDBA',loc_index_name); indx_count := indx_count + 1; END LOOP; CLOSE c2; END LOOP; CLOSE c1; -- insert a record into the job log INSERT INTO WTW_JOB_LOG(JOB_NAME, RUN_DATE, START_TIME, END_TIME, MSG_TXT) VALUES('Wtw_Gather_Statistics',SYSDATE,loc_start_time, SYSDATE,INITCAP('SCHEMA Stats Complete') || CHR(10) || tbl_count || INITCAP(' TABLES Analyzed ') || CHR(10) || indx_count || INITCAP(' INDEXES Analyzed')); COMMIT; END; Tom Mercadante Oracle Certified Professional -Original Message- Sent: Wednesday, October 08, 2003 4:54 PM To: Multiple recipients of list ORACLE-L How does one keep CBO statistics for an applications base tables up to date? We are about to implement the CBO any must read documents. Many thanks bob -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Bob Metelsky INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (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.net -- Author: Mercadante, Thomas F INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (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.net -- Author: [EMAIL PROTECTED] INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an
RE: how to keep statistics up to date for CBO
Thank you very much Tom. That gives me an excellent starting point. I'll begin to implement this in a devel environment and get a feel for it. Thanks again! bob -Original Message- Sent: Thursday, October 09, 2003 9:00 AM To: Multiple recipients of list ORACLE-L Bob, I do the following: First, alter all tables turning monitoring on: alter table {table name} monitoring; Monitoring says: Specify MONITORING if you want Oracle to collect modification statistics on table. These statistics are estimates of the number of rows affected by DML statements over a particular period of time. They are available for use by the optimizer or for analysis by the user. Then use the following. It recalculates stats for those tables that have been changed enough to warrant stats. The User_Tab_Modifications table will hold a record if 10% of the table was changed. I've been using this for a while now, and it seems to be working fine. As you can see, I have a database table that I insert a record into so I can see how much work is done. I'm happy with it. And I'm not gathering stats for tables that I don't need to. I run this job daily. Hope this helps. PROCEDURE WTWDBA.Wtw_Gather_Statistics IS /* Procedure Name : Wtw_Gather_Statistics Author : Tom Mercadante Mercadante Systems Design June 14, 2001 Purpose: This Package will use the System DBMS_STATS package to gather statistics for both tables and indexes. */ loc_table_name USER_TABLES.TABLE_NAME%TYPE; loc_index_name USER_INDEXES.INDEX_NAME%TYPE; tbl_count NUMBER := 0; indx_count NUMBER := 0; loc_start_time DATE; CURSOR c1 IS SELECT ut.table_name FROM USER_TABLES UT, USER_TAB_MODIFICATIONS UTM WHERE UT.TABLE_NAME = UTM.table_name; CURSOR c2 IS SELECT index_name FROM USER_INDEXES WHERE table_name = loc_table_name; BEGIN loc_start_time := SYSDATE; -- Gather statistics on tables OPEN c1; LOOP FETCH c1 INTO loc_table_name; EXIT WHEN c1%NOTFOUND; dbms_stats.gather_table_stats('WTWDBA',loc_table_name); tbl_count := tbl_count + 1; -- Gather statistics on indexes OPEN c2; LOOP FETCH c2 INTO loc_index_name; EXIT WHEN c2%NOTFOUND; dbms_stats.gather_index_stats('WTWDBA',loc_index_name); indx_count := indx_count + 1; END LOOP; CLOSE c2; END LOOP; CLOSE c1; -- insert a record into the job log INSERT INTO WTW_JOB_LOG(JOB_NAME, RUN_DATE, START_TIME, END_TIME, MSG_TXT) VALUES('Wtw_Gather_Statistics',SYSDATE,loc_start_time, SYSDATE,INITCAP('SCHEMA Stats Complete') || CHR(10) || tbl_count || INITCAP(' TABLES Analyzed ') || CHR(10) || indx_count || INITCAP(' INDEXES Analyzed')); COMMIT; END; Tom Mercadante Oracle Certified Professional -Original Message- Sent: Wednesday, October 08, 2003 4:54 PM To: Multiple recipients of list ORACLE-L How does one keep CBO statistics for an applications base tables up to date? We are about to implement the CBO any must read documents. Many thanks bob -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Bob Metelsky INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (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.net -- Author: Mercadante, Thomas F INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (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.net -- Author: Bob Metelsky INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L
RE: how to keep statistics up to date for CBO
Title: RE: how to keep statistics up to date for CBO Tom, why would you want to collect table/index stats separately? Any reason? I prefer cascade=true with mine. Raj Rajendra dot Jamadagni at nospamespn dot com All Views expressed in this email are strictly personal. QOTD: Any clod can have facts, having an opinion is an art ! -Original Message- From: Bob Metelsky [mailto:[EMAIL PROTECTED]] Sent: Thursday, October 09, 2003 9:49 AM To: Multiple recipients of list ORACLE-L Subject: RE: how to keep statistics up to date for CBO Thank you very much Tom. That gives me an excellent starting point. I'll begin to implement this in a devel environment and get a feel for it. Thanks again! bob -Original Message- Sent: Thursday, October 09, 2003 9:00 AM To: Multiple recipients of list ORACLE-L Bob, I do the following: First, alter all tables turning monitoring on: alter table {table name} monitoring; Monitoring says: Specify MONITORING if you want Oracle to collect modification statistics on table. These statistics are estimates of the number of rows affected by DML statements over a particular period of time. They are available for use by the optimizer or for analysis by the user. Then use the following. It recalculates stats for those tables that have been changed enough to warrant stats. The User_Tab_Modifications table will hold a record if 10% of the table was changed. I've been using this for a while now, and it seems to be working fine. As you can see, I have a database table that I insert a record into so I can see how much work is done. I'm happy with it. And I'm not gathering stats for tables that I don't need to. I run this job daily. Hope this helps. PROCEDURE WTWDBA.Wtw_Gather_Statistics IS /* Procedure Name : Wtw_Gather_Statistics Author : Tom Mercadante Mercadante Systems Design June 14, 2001 Purpose : This Package will use the System DBMS_STATS package to gather statistics for both tables and indexes. */ loc_table_name USER_TABLES.TABLE_NAME%TYPE; loc_index_name USER_INDEXES.INDEX_NAME%TYPE; tbl_count NUMBER := 0; indx_count NUMBER := 0; loc_start_time DATE; CURSOR c1 IS SELECT ut.table_name FROM USER_TABLES UT, USER_TAB_MODIFICATIONS UTM WHERE UT.TABLE_NAME = UTM.table_name; CURSOR c2 IS SELECT index_name FROM USER_INDEXES WHERE table_name = loc_table_name; BEGIN loc_start_time := SYSDATE; -- Gather statistics on tables OPEN c1; LOOP FETCH c1 INTO loc_table_name; EXIT WHEN c1%NOTFOUND; dbms_stats.gather_table_stats('WTWDBA',loc_table_name); tbl_count := tbl_count + 1; -- Gather statistics on indexes OPEN c2; LOOP FETCH c2 INTO loc_index_name; EXIT WHEN c2%NOTFOUND; dbms_stats.gather_index_stats('WTWDBA',loc_index_name); indx_count := indx_count + 1; END LOOP; CLOSE c2; END LOOP; CLOSE c1; -- insert a record into the job log INSERT INTO WTW_JOB_LOG(JOB_NAME, RUN_DATE, START_TIME, END_TIME, MSG_TXT) VALUES('Wtw_Gather_Statistics',SYSDATE,loc_start_time, SYSDATE,INITCAP('SCHEMA Stats Complete') || CHR(10) || tbl_count || INITCAP(' TABLES Analyzed ') || CHR(10) || indx_count || INITCAP(' INDEXES Analyzed')); COMMIT; END; Tom Mercadante Oracle Certified Professional -Original Message- Sent: Wednesday, October 08, 2003 4:54 PM To: Multiple recipients of list ORACLE-L How does one keep CBO statistics for an applications base tables up to date? We are about to implement the CBO any must read documents. Many thanks bob -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Bob Metelsky INET: [EMAIL PROTECTED] Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (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.net -- Author: Mercadante, Thomas F INET: [EMAIL PROTECTED] Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (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.net -- Author: Bob Metelsky INET: [EMAIL PROTECTED] Fat
RE: how to keep statistics up to date for CBO
Title: RE: how to keep statistics up to date for CBO Raj, Of course you are correct. I didn't see the "cascade" option until just recently. And I'm a bit lazy. And it's currently working just fine. Need any other lazy-a**ed excuses? :) Tom Mercadante Oracle Certified Professional -Original Message-From: Jamadagni, Rajendra [mailto:[EMAIL PROTECTED]Sent: Thursday, October 09, 2003 10:45 AMTo: Multiple recipients of list ORACLE-LSubject: RE: how to keep statistics up to date for CBO Tom, why would you want to collect table/index stats separately? Any reason? I prefer cascade=true with mine. Raj Rajendra dot Jamadagni at nospamespn dot com All Views expressed in this email are strictly personal. QOTD: Any clod can have facts, having an opinion is an art ! -Original Message- From: Bob Metelsky [mailto:[EMAIL PROTECTED]] Sent: Thursday, October 09, 2003 9:49 AM To: Multiple recipients of list ORACLE-L Subject: RE: how to keep statistics up to date for CBO Thank you very much Tom. That gives me an excellent starting point. I'll begin to implement this in a devel environment and get a feel for it. Thanks again! bob -Original Message- Sent: Thursday, October 09, 2003 9:00 AM To: Multiple recipients of list ORACLE-L Bob, I do the following: First, alter all tables turning monitoring on: alter table {table name} monitoring; Monitoring says: "Specify MONITORING if you want Oracle to collect modification statistics on table. These statistics are estimates of the number of rows affected by DML statements over a particular period of time. They are available for use by the optimizer or for analysis by the user." Then use the following. It recalculates stats for those tables that have been changed enough to warrant stats. The User_Tab_Modifications table will hold a record if 10% of the table was changed. I've been using this for a while now, and it seems to be working fine. As you can see, I have a database table that I insert a record into so I can see how much work is done. I'm happy with it. And I'm not gathering stats for tables that I don't need to. I run this job daily. Hope this helps. PROCEDURE WTWDBA.Wtw_Gather_Statistics IS /* Procedure Name : Wtw_Gather_Statistics Author : Tom Mercadante Mercadante Systems Design June 14, 2001 Purpose : This Package will use the System DBMS_STATS package to gather statistics for both tables and indexes. */ loc_table_name USER_TABLES.TABLE_NAME%TYPE; loc_index_name USER_INDEXES.INDEX_NAME%TYPE; tbl_count NUMBER := 0; indx_count NUMBER := 0; loc_start_time DATE; CURSOR c1 IS SELECT ut.table_name FROM USER_TABLES UT, USER_TAB_MODIFICATIONS UTM WHERE UT.TABLE_NAME = UTM.table_name; CURSOR c2 IS SELECT index_name FROM USER_INDEXES WHERE table_name = loc_table_name; BEGIN loc_start_time := SYSDATE; -- Gather statistics on tables OPEN c1; LOOP FETCH c1 INTO loc_table_name; EXIT WHEN c1%NOTFOUND; dbms_stats.gather_table_stats('WTWDBA',loc_table_name); tbl_count := tbl_count + 1; -- Gather statistics on indexes OPEN c2; LOOP FETCH c2 INTO loc_index_name; EXIT WHEN c2%NOTFOUND; dbms_stats.gather_index_stats('WTWDBA',loc_index_name); indx_count := indx_count + 1; END LOOP; CLOSE c2; END LOOP; CLOSE c1; -- insert a record into the job log INSERT INTO WTW_JOB_LOG(JOB_NAME, RUN_DATE, START_TIME, END_TIME, MSG_TXT) VALUES('Wtw_Gather_Statistics',SYSDATE,loc_start_time, SYSDATE,INITCAP('SCHEMA Stats Complete') || CHR(10) || tbl_count || INITCAP(' TABLES Analyzed ') || CHR(10) || indx_count || INITCAP(' INDEXES Analyzed')); COMMIT; END; Tom Mercadante Oracle Certified Professional -Original Message- Sent: Wednesday, October 08, 2003 4:54 PM To: Multiple recipients of list ORACLE-L How does one keep CBO statistics for an applications base tables up to date? We are about to implement the CBO any must read documents. Many thanks bob -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Bob Metelsky INET: [EMAIL PROTECTED] Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (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:
RE: how to keep statistics up to date for CBO
Title: RE: how to keep statistics up to date for CBO Likewise all my options are shaken .. not stirred . Raj Rajendra dot Jamadagni at nospamespn dot com All Views expressed in this email are strictly personal. QOTD: Any clod can have facts, having an opinion is an art ! -Original Message-From: Mercadante, Thomas F [mailto:[EMAIL PROTECTED]Sent: Thursday, October 09, 2003 11:10 AMTo: Multiple recipients of list ORACLE-LSubject: RE: how to keep statistics up to date for CBO Raj, Of course you are correct. I didn't see the "cascade" option until just recently. And I'm a bit lazy. And it's currently working just fine. Need any other lazy-a**ed excuses? :) Tom Mercadante Oracle Certified Professional This e-mail message is confidential, intended only for the named recipient(s) above and may contain information that is privileged, attorney work product or exempt from disclosure under applicable law. If you have received this message in error, or are not the named recipient(s), please immediately notify corporate MIS at (860) 766-2000 and delete this e-mail message from your computer, Thank you.*2
RE: how to keep statistics up to date for CBO
One reason to collect index stats separately would be if you use estimate for the collection of the table statistics. In that case I collect the index stats separately with a compute. Index statistics collection is fast enough to always go for exact statistics rather than sampling. At 08:44 AM 10/9/2003, you wrote: Tom, why would you want to collect table/index stats separately? Any reason? I prefer cascade=true with mine. Raj Rajendra dot Jamadagni at nospamespn dot com All Views expressed in this email are strictly personal. QOTD: Any clod can have facts, having an opinion is an art ! -Original Message- From: Bob Metelsky [mailto:[EMAIL PROTECTED]mailto:[EMAIL PROTECTED] Sent: Thursday, October 09, 2003 9:49 AM To: Multiple recipients of list ORACLE-L Subject: RE: how to keep statistics up to date for CBO Thank you very much Tom. That gives me an excellent starting point. I'll begin to implement this in a devel environment and get a feel for it. Thanks again! bob -Original Message- Sent: Thursday, October 09, 2003 9:00 AM To: Multiple recipients of list ORACLE-L Bob, I do the following: First, alter all tables turning monitoring on: alter table {table name} monitoring; Monitoring says: Specify MONITORING if you want Oracle to collect modification statistics on table. These statistics are estimates of the number of rows affected by DML statements over a particular period of time. They are available for use by the optimizer or for analysis by the user. Then use the following. It recalculates stats for those tables that have been changed enough to warrant stats. The User_Tab_Modifications table will hold a record if 10% of the table was changed. I've been using this for a while now, and it seems to be working fine. As you can see, I have a database table that I insert a record into so I can see how much work is done. I'm happy with it. And I'm not gathering stats for tables that I don't need to. I run this job daily. Hope this helps. PROCEDURE WTWDBA.Wtw_Gather_Statistics IS /* Procedure Name : Wtw_Gather_Statistics Author : Tom Mercadante Mercadante Systems Design June 14, 2001 Purpose: This Package will use the System DBMS_STATS package to gather statistics for both tables and indexes. */ loc_table_name USER_TABLES.TABLE_NAME%TYPE; loc_index_name USER_INDEXES.INDEX_NAME%TYPE; tbl_count NUMBER := 0; indx_count NUMBER := 0; loc_start_time DATE; CURSOR c1 IS SELECT ut.table_name FROM USER_TABLES UT, USER_TAB_MODIFICATIONS UTM WHERE UT.TABLE_NAME = UTM.table_name; CURSOR c2 IS SELECT index_name FROM USER_INDEXES WHERE table_name = loc_table_name; BEGIN loc_start_time := SYSDATE; -- Gather statistics on tables OPEN c1; LOOP FETCH c1 INTO loc_table_name; EXIT WHEN c1%NOTFOUND; dbms_stats.gather_table_stats('WTWDBA',loc_table_name); tbl_count := tbl_count + 1; -- Gather statistics on indexes OPEN c2; LOOP FETCH c2 INTO loc_index_name; EXIT WHEN c2%NOTFOUND; dbms_stats.gather_index_stats('WTWDBA',loc_index_name); indx_count := indx_count + 1; END LOOP; CLOSE c2; END LOOP; CLOSE c1; -- insert a record into the job log INSERT INTO WTW_JOB_LOG(JOB_NAME, RUN_DATE, START_TIME, END_TIME, MSG_TXT) VALUES('Wtw_Gather_Statistics',SYSDATE,loc_start_time, SYSDATE,INITCAP('SCHEMA Stats Complete') || CHR(10) || tbl_count || INITCAP(' TABLES Analyzed ') || CHR(10) || indx_count || INITCAP(' INDEXES Analyzed')); COMMIT; END; Tom Mercadante Oracle Certified Professional -Original Message- Sent: Wednesday, October 08, 2003 4:54 PM To: Multiple recipients of list ORACLE-L How does one keep CBO statistics for an applications base tables up to date? We are about to implement the CBO any must read documents. Many thanks bob -- Please see the official ORACLE-L FAQ: http://www.orafaq.nethttp://www.orafaq.net -- Author: Bob Metelsky INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.comhttp://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (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.nethttp://www.orafaq.net -- Author: Mercadante, Thomas F INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.comhttp://www.fatcity.com San
RE: how to keep statistics up to date for CBO
Title: RE: how to keep statistics up to date for CBO So Wolfgang, in that case, should _wait_ till table stats (which are probably estimate) are complete to perform index stats (which you recommend compute) or can that happen in parallel. Raj Rajendra dot Jamadagni at nospamespn dot com All Views expressed in this email are strictly personal. QOTD: Any clod can have facts, having an opinion is an art ! -Original Message- From: Wolfgang Breitling [mailto:[EMAIL PROTECTED]] Sent: Thursday, October 09, 2003 11:40 AM To: Multiple recipients of list ORACLE-L Subject: RE: how to keep statistics up to date for CBO One reason to collect index stats separately would be if you use estimate for the collection of the table statistics. In that case I collect the index stats separately with a compute. Index statistics collection is fast enough to always go for exact statistics rather than sampling. **This e-mail message is confidential, intended only for the named recipient(s) above and may contain information that is privileged, attorney work product or exempt from disclosure under applicable law. If you have received this message in error, or are not the named recipient(s), please immediately notify corporate MIS at (860) 766-2000 and delete this e-mail message from your computer, Thank you.**5
RE: how to keep statistics up to date for CBO
I don't see any reason why that couldn't happen concurrently. The table and its indexes are different physical segments. At 09:59 AM 10/9/2003, you wrote: So Wolfgang, in that case, should _wait_ till table stats (which are probably estimate) are complete to perform index stats (which you recommend compute) or can that happen in parallel. Raj Rajendra dot Jamadagni at nospamespn dot com All Views expressed in this email are strictly personal. QOTD: Any clod can have facts, having an opinion is an art ! -Original Message- From: Wolfgang Breitling [mailto:[EMAIL PROTECTED]mailto:[EMAIL PROTECTED] Sent: Thursday, October 09, 2003 11:40 AM To: Multiple recipients of list ORACLE-L Subject: RE: how to keep statistics up to date for CBO One reason to collect index stats separately would be if you use estimate for the collection of the table statistics. In that case I collect the index stats separately with a compute. Index statistics collection is fast enough to always go for exact statistics rather than sampling. ** This e-mail message is confidential, intended only for the named recipient(s) above and may contain information that is privileged, attorney work product or exempt from disclosure under applicable law. If you have received this message in error, or are not the named recipient(s), please immediately notify corporate MIS at (860) 766-2000 and delete this e-mail message from your computer, Thank you. **5 Wolfgang Breitling Oracle7, 8, 8i, 9i OCP DBA Centrex Consulting Corporation http://www.centrexcc.com -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Wolfgang Breitling INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (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).
RE: RE: how to keep statistics up to date for CBO
None that I've noticed the database in question is processing something like 1B transactions per day. Dick Goulet Senior Oracle DBA Oracle Certified 8i DBA -Original Message- Sent: Thursday, October 09, 2003 9:14 AM To: Multiple recipients of list ORACLE-L does monitoring have any real overhead in a high transaction system? From: Mercadante, Thomas F [EMAIL PROTECTED] Date: 2003/10/09 Thu AM 08:59:33 EDT To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] Subject: RE: how to keep statistics up to date for CBO Bob, I do the following: First, alter all tables turning monitoring on: alter table {table name} monitoring; Monitoring says: Specify MONITORING if you want Oracle to collect modification statistics on table. These statistics are estimates of the number of rows affected by DML statements over a particular period of time. They are available for use by the optimizer or for analysis by the user. Then use the following. It recalculates stats for those tables that have been changed enough to warrant stats. The User_Tab_Modifications table will hold a record if 10% of the table was changed. I've been using this for a while now, and it seems to be working fine. As you can see, I have a database table that I insert a record into so I can see how much work is done. I'm happy with it. And I'm not gathering stats for tables that I don't need to. I run this job daily. Hope this helps. PROCEDURE WTWDBA.Wtw_Gather_Statistics IS /* Procedure Name : Wtw_Gather_Statistics Author : Tom Mercadante Mercadante Systems Design June 14, 2001 Purpose: This Package will use the System DBMS_STATS package to gather statistics for both tables and indexes. */ loc_table_name USER_TABLES.TABLE_NAME%TYPE; loc_index_name USER_INDEXES.INDEX_NAME%TYPE; tbl_count NUMBER := 0; indx_count NUMBER := 0; loc_start_time DATE; CURSOR c1 IS SELECT ut.table_name FROM USER_TABLES UT, USER_TAB_MODIFICATIONS UTM WHERE UT.TABLE_NAME = UTM.table_name; CURSOR c2 IS SELECT index_name FROM USER_INDEXES WHERE table_name = loc_table_name; BEGIN loc_start_time := SYSDATE; -- Gather statistics on tables OPEN c1; LOOP FETCH c1 INTO loc_table_name; EXIT WHEN c1%NOTFOUND; dbms_stats.gather_table_stats('WTWDBA',loc_table_name); tbl_count := tbl_count + 1; -- Gather statistics on indexes OPEN c2; LOOP FETCH c2 INTO loc_index_name; EXIT WHEN c2%NOTFOUND; dbms_stats.gather_index_stats('WTWDBA',loc_index_name); indx_count := indx_count + 1; END LOOP; CLOSE c2; END LOOP; CLOSE c1; -- insert a record into the job log INSERT INTO WTW_JOB_LOG(JOB_NAME, RUN_DATE, START_TIME, END_TIME, MSG_TXT) VALUES('Wtw_Gather_Statistics',SYSDATE,loc_start_time, SYSDATE,INITCAP('SCHEMA Stats Complete') || CHR(10) || tbl_count || INITCAP(' TABLES Analyzed ') || CHR(10) || indx_count || INITCAP(' INDEXES Analyzed')); COMMIT; END; Tom Mercadante Oracle Certified Professional -Original Message- Sent: Wednesday, October 08, 2003 4:54 PM To: Multiple recipients of list ORACLE-L How does one keep CBO statistics for an applications base tables up to date? We are about to implement the CBO any must read documents. Many thanks bob -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Bob Metelsky INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (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.net -- Author: Mercadante, Thomas F INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (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.net -- Author: [EMAIL PROTECTED] INET: [EMAIL
RE: how to keep statistics up to date for CBO
Only thing I'd add I like to compute exact stats for any table less than 'n' rows (where 'n' is small and you can insert your own value here). Nothing to do with the performance of the stats collection itself, more the access plans that subsequently result. If the optimizer thinks a table has 100 million rows instead of 90 million, then its unlikely to dramatically affect the outcome of the access path evaluation, so small sampling when doing the stats should be fine. But the optimizer thinks a 200 row table only has 100 rows, then you can end up with lots of grief (especially in nested loop scenarios) so a compute may well be the best option hth connor --- Wolfgang Breitling [EMAIL PROTECTED] wrote: One reason to collect index stats separately would be if you use estimate for the collection of the table statistics. In that case I collect the index stats separately with a compute. Index statistics collection is fast enough to always go for exact statistics rather than sampling. At 08:44 AM 10/9/2003, you wrote: Tom, why would you want to collect table/index stats separately? Any reason? I prefer cascade=true with mine. Raj Rajendra dot Jamadagni at nospamespn dot com All Views expressed in this email are strictly personal. QOTD: Any clod can have facts, having an opinion is an art ! -Original Message- From: Bob Metelsky [mailto:[EMAIL PROTECTED]mailto:[EMAIL PROTECTED] Sent: Thursday, October 09, 2003 9:49 AM To: Multiple recipients of list ORACLE-L Subject: RE: how to keep statistics up to date for CBO Thank you very much Tom. That gives me an excellent starting point. I'll begin to implement this in a devel environment and get a feel for it. Thanks again! bob -Original Message- Sent: Thursday, October 09, 2003 9:00 AM To: Multiple recipients of list ORACLE-L Bob, I do the following: First, alter all tables turning monitoring on: alter table {table name} monitoring; Monitoring says: Specify MONITORING if you want Oracle to collect modification statistics on table. These statistics are estimates of the number of rows affected by DML statements over a particular period of time. They are available for use by the optimizer or for analysis by the user. Then use the following. It recalculates stats for those tables that have been changed enough to warrant stats. The User_Tab_Modifications table will hold a record if 10% of the table was changed. I've been using this for a while now, and it seems to be working fine. As you can see, I have a database table that I insert a record into so I can see how much work is done. I'm happy with it. And I'm not gathering stats for tables that I don't need to. I run this job daily. Hope this helps. PROCEDURE WTWDBA.Wtw_Gather_Statistics IS /* Procedure Name : Wtw_Gather_Statistics Author : Tom Mercadante Mercadante Systems Design June 14, 2001 Purpose: This Package will use the System DBMS_STATS package to gather statistics for both tables and indexes. */ loc_table_name USER_TABLES.TABLE_NAME%TYPE; loc_index_name USER_INDEXES.INDEX_NAME%TYPE; tbl_count NUMBER := 0; indx_count NUMBER := 0; loc_start_time DATE; CURSOR c1 IS SELECT ut.table_name FROM USER_TABLES UT, USER_TAB_MODIFICATIONS UTM WHERE UT.TABLE_NAME = UTM.table_name; CURSOR c2 IS SELECT index_name FROM USER_INDEXES WHERE table_name = loc_table_name; BEGIN loc_start_time := SYSDATE; -- Gather statistics on tables OPEN c1; LOOP FETCH c1 INTO loc_table_name; EXIT WHEN c1%NOTFOUND; dbms_stats.gather_table_stats('WTWDBA',loc_table_name); tbl_count := tbl_count + 1; -- Gather statistics on indexes OPEN c2; LOOP FETCH c2 INTO loc_index_name; EXIT WHEN c2%NOTFOUND; dbms_stats.gather_index_stats('WTWDBA',loc_index_name); indx_count := indx_count + 1; END LOOP; CLOSE c2; END LOOP; CLOSE c1; -- insert a record into the job log INSERT INTO WTW_JOB_LOG(JOB_NAME, RUN_DATE, START_TIME, END_TIME, MSG_TXT) VALUES('Wtw_Gather_Statistics',SYSDATE,loc_start_time, SYSDATE,INITCAP('SCHEMA Stats Complete') || CHR(10) || tbl_count || INITCAP(' TABLES Analyzed ') || CHR(10) || indx_count || INITCAP(' INDEXES Analyzed')); COMMIT; END; Tom Mercadante Oracle Certified Professional -Original Message- Sent: Wednesday, October 08, 2003 4:54 PM To: Multiple recipients of list ORACLE-L How does one keep CBO statistics for an applications base tables up to date? We are about to implement the CBO any must read documents. Many thanks bob
RE: how to keep statistics up to date for CBO
Title: RE: how to keep statistics up to date for CBO I like to use a cron job that runs the following in SQL Plus: begin dbms_stats.gather_schema_stats(ownname= 'YOUR_SCHEMA_NAME', options= 'GATHER AUTO'); end; You should search the Oracle docs for your version of Oracle (you didn't specify version) to determine the best method for gathering statistics. You'll also see the different options there, like GATHER AUTO, which lets Oracle determine when it's time to compute new statistics for tables and indexes. For 9iR2, the best method for CBO is dbms_stats, rather than analyze table compute statistics, according to the Oracle docs. Best regards, David B. Wagoner Database Administrator Arsenal Digital Solutions Web: http://www.arsenaldigital.com the most trusted source for STORAGE MANAGEMENT SERVICES The contents of this e-mail message may be privileged and/or confidential. If you are not the intended recipient, any review, dissemination, copying, distribution or other use of the contents of this message or any attachment by you is strictly prohibited. If you receive this communication in error, please notify us immediately by return e-mail or by telephone (919-466-6700), and please delete this message and all attachments from your system. Thank you. -Original Message- From: Bob Metelsky [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 08, 2003 4:54 PM To: Multiple recipients of list ORACLE-L Subject: how to keep statistics up to date for CBO How does one keep CBO statistics for an applications base tables up to date? We are about to implement the CBO any must read documents. Many thanks bob -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Bob Metelsky INET: [EMAIL PROTECTED] Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (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).
RE: how to keep statistics up to date for CBO
Bob, How does one keep CBO statistics for an applications base tables up to date? We are about to implement the CBO any must read documents. I wouldn't call it 'must-read', but you can browse my RBO-to-CBO paper at 'http://www.geocities.com/john_sharmila/links.htm' (click on the paper link). It deals with a few things that you can trip up on. I should probably update it with 9iR2 specific stuff, but haven't yet had the time :( And of course, Tim's CBO paper at http://www.evdbt.com' *is* a must-read! John Kanagaraj DB Soft Inc Phone: 408-970-7002 (W) Listen to great, commercial-free christian music 24x7x365 at http://www.klove.com ** The opinions and facts contained in this message are entirely mine and do not reflect those of my employer or customers ** -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: John Kanagaraj INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (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).