Oracle 11g has introduced a hell lot of new features related to Parallel Execution – like statement queuing, in-memory PX and auto-DOP, to name a few. There are also small bits of enhancements here and there – like default value of the PARALLEL_EXECUTION_MESSAGE_SIZE and an introduction of an easy way to stick PX slaves to a current RAC node with PARALLEL_FORCE_LOCAL.
Jonathan Lewis reminded me on my last post that using SQL Profiles (because they are part of the SQL Tuning Advisor) requires a license for Oracle Tuning Pack (which requires a license for the Diagnostics Pack). He also mentioned that Baselines did not require any additional license (at least creating and using Baselines on SQL statements). It’s been a while since I worked on a database that didn’t have both packs, but frankly I wasn’t sure I had a good handle of what was allowed and what wasn’t. So I thought it might be worthwhile to check. There is an easy way to check by the way. I did a post a while back on Tuning Pack and Diagnostic Pack license requirements for running AWR and how to check what was allowed and what wasn’t using the CONTROL_MANAGEMENT_PACK_ACCESS parameter. Here’s a link to the post:
Here’s an example using the same technique to show that SQL Profiles are indeed disabled by turning off the Diagnostic and Tuning Packs (at least on 11.2.02).
SQL*Plus: Release 11.2.0.2.0 Production on Fri Jan 7 21:15:21 2011 Copyright (c) 1982, 2010, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SYS@SANDBOX1> @parms Enter value for parameter: management_pack Enter value for isset: Enter value for show_hidden: NAME VALUE ISDEFAUL ISMODIFIED ISSET -------------------------------------------------- ---------------------------------------------------------------------- -------- ---------- ---------- control_management_pack_access DIAGNOSTIC+TUNING TRUE TRUE TRUE SYS@SANDBOX1> @flush_pool System altered. SYS@SANDBOX1> @avgskew AVG(PK_COL) ----------- 16093748.8 1 row selected. SYS@SANDBOX1> / AVG(PK_COL) ----------- 16093748.8 1 row selected. SYS@SANDBOX1> @dplan Enter value for sql_id: 05cq2hb1r37tr Enter value for child_no: PLAN_TABLE_OUTPUT ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- SQL_ID 05cq2hb1r37tr, child number 0 ------------------------------------- select avg(pk_col) from kso.skew a where col1 > 0 Plan hash value: 568322376 ----------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ----------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 44486 (100)| | | 1 | SORT AGGREGATE | | 1 | 11 | | | |* 2 | TABLE ACCESS STORAGE FULL| SKEW | 32M| 335M| 44486 (1)| 00:08:54 | ----------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - storage("COL1">0) filter("COL1">0) Note ----- - SQL profile PROF_05cq2hb1r37tr_568322376 used for this statement 24 rows selected. SYS@SANDBOX1> @flush_pool System altered. SYS@SANDBOX1> alter system set control_management_pack_access='none'; System altered. SYS@SANDBOX1> @avgskew AVG(PK_COL) ----------- 16093748.8 1 row selected. SYS@SANDBOX1> / AVG(PK_COL) ----------- 16093748.8 1 row selected. SYS@SANDBOX1> @dplan Enter value for sql_id: 05cq2hb1r37tr Enter value for child_no: PLAN_TABLE_OUTPUT ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- SQL_ID 05cq2hb1r37tr, child number 0 ------------------------------------- select avg(pk_col) from kso.skew a where col1 > 0 Plan hash value: 568322376 ----------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ----------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 44486 (100)| | | 1 | SORT AGGREGATE | | 1 | 11 | | | |* 2 | TABLE ACCESS STORAGE FULL| SKEW | 32M| 335M| 44486 (1)| 00:08:54 | ----------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - storage("COL1">0) filter("COL1">0) 20 rows selected. SYS@SANDBOX1> alter system set control_management_pack_access='DIAGNOSTIC+TUNING'; System altered. SYS@SANDBOX1> @flush_pool System altered. SYS@SANDBOX1> @avgskew AVG(PK_COL) ----------- 16093748.8 1 row selected. SYS@SANDBOX1> / AVG(PK_COL) ----------- 16093748.8 1 row selected. SYS@SANDBOX1> @dplan Enter value for sql_id: 05cq2hb1r37tr Enter value for child_no: PLAN_TABLE_OUTPUT ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- SQL_ID 05cq2hb1r37tr, child number 0 ------------------------------------- select avg(pk_col) from kso.skew a where col1 > 0 Plan hash value: 568322376 ----------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ----------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 44486 (100)| | | 1 | SORT AGGREGATE | | 1 | 11 | | | |* 2 | TABLE ACCESS STORAGE FULL| SKEW | 32M| 335M| 44486 (1)| 00:08:54 | ----------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - storage("COL1">0) filter("COL1">0) Note ----- - SQL profile PROF_05cq2hb1r37tr_568322376 used for this statement 24 rows selected. |
So as you can see, there was a SQL Profile on the statement that was used when Diagnostic and Tuning Packs were enabled, but when I set CONTROL_MANAGEMENT_PACK_ACCESS to NONE, the SQL Profile was ignored. Let’s try the same test with a Baseline.
SYS@SANDBOX1> @flush_pool System altered. SYS@SANDBOX1> @avgskew AVG(PK_COL) ----------- 16093748.8 SYS@SANDBOX1> @create_baseline Enter value for sql_id: 05cq2hb1r37tr Enter value for plan_hash_value: 568322376 Enter value for fixed (NO): Enter value for enabled (YES): Enter value for plan_name (SQLID_sqlid_planhashvalue): sql_id: 05cq2hb1r37tr plan_hash_value: 568322376 fixed: NO enabled: YES Baseline SQLID_05cq2hb1r37tr_568322376 created. PL/SQL procedure successfully completed. SYS@SANDBOX1> @avgskew AVG(PK_COL) ----------- 16093748.8 SYS@SANDBOX1> / AVG(PK_COL) ----------- 16093748.8 SYS@SANDBOX1> @dplan Enter value for sql_id: 05cq2hb1r37tr Enter value for child_no: PLAN_TABLE_OUTPUT ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- SQL_ID 05cq2hb1r37tr, child number 0 ------------------------------------- select avg(pk_col) from kso.skew a where col1 > 0 Plan hash value: 568322376 ----------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ----------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 44486 (100)| | | 1 | SORT AGGREGATE | | 1 | 11 | | | |* 2 | TABLE ACCESS STORAGE FULL| SKEW | 32M| 335M| 44486 (1)| 00:08:54 | ----------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - storage("COL1">0) filter("COL1">0) Note ----- - SQL profile PROF_05cq2hb1r37tr_568322376 used for this statement - SQL plan baseline SQLID_05CQ2HB1R37TR_568322376 used for this statement 25 rows selected. SYS@SANDBOX1> -- so Baseline and SQL Profile Used SYS@SANDBOX1> SYS@SANDBOX1> alter system set control_management_pack_access='none'; System altered. SYS@SANDBOX1> @flush_pool System altered. SYS@SANDBOX1> @avgskew AVG(PK_COL) ----------- 16093748.8 SYS@SANDBOX1> / AVG(PK_COL) ----------- 16093748.8 SYS@SANDBOX1> @dplan Enter value for sql_id: 05cq2hb1r37tr Enter value for child_no: PLAN_TABLE_OUTPUT ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- SQL_ID 05cq2hb1r37tr, child number 0 ------------------------------------- select avg(pk_col) from kso.skew a where col1 > 0 Plan hash value: 568322376 ----------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ----------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 44486 (100)| | | 1 | SORT AGGREGATE | | 1 | 11 | | | |* 2 | TABLE ACCESS STORAGE FULL| SKEW | 32M| 335M| 44486 (1)| 00:08:54 | ----------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - storage("COL1">0) filter("COL1">0) Note ----- - SQL plan baseline SQLID_05CQ2HB1R37TR_568322376 used for this statement 24 rows selected. |
So Baselines apparently do not require licenses for the Tuning and Diagnostics Packs, at least they aren’t disabled by setting the CONTROL_MANAGEMENT_PACK_ACCESS parameter to NONE.
In a previous post (GATHER_PLAN_STATISTICS) I mentioned that SQL Profiles and Baselines can both be applied to a single statement. In this case, it appears that the hints are merged. The Notes section of the XPLAN output shows that both the Baseline and the Profile are in effect. I wanted to prove to myself that the hints from both the Profile and Baseline were indeed applied. So here’s my simple test case:
Basic Design For the Test:
> !sql sqlplus "/ as sysdba" SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 2 20:09:53 2010 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SYS@LAB112> -- first the set up SYS@LAB112> -- 32M row table with an index on col1 SYS@LAB112> !cat avgskewi.sql select avg(pk_col) from kso.skew where col1 = 136133 / SYS@LAB112> @avgskewi AVG(PK_COL) ----------- 15636133 1 row selected. Elapsed: 00:00:00.00 SYS@LAB112> SYS@LAB112> @find_sql Enter value for sql_text: %where col1 = 136133% Enter value for sql_id: SQL_ID CHILD PLAN_HASH EXECS AVG_ETIME AVG_LIO SQL_TEXT ------------- ------ ---------- ---------- ------------- ------------ ------------------------------------------------------------ 84q0zxfzn5u6s 0 3723858078 3 .00 36 select avg(pk_col) from kso.skew where col1 = 136133 1 row selected. Elapsed: 00:00:00.12 SYS@LAB112> SYS@LAB112> @dplan Enter value for sql_id: 84q0zxfzn5u6s Enter value for child_no: PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------ SQL_ID 84q0zxfzn5u6s, child number 0 ------------------------------------- select avg(pk_col) from kso.skew where col1 = 136133 Plan hash value: 3723858078 ------------------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | | | 35 (100)| | | 1 | SORT AGGREGATE | | 1 | 24 | | | | 2 | TABLE ACCESS BY INDEX ROWID| SKEW | 35 | 840 | 35 (0)| 00:00:01 | |* 3 | INDEX RANGE SCAN | SKEW_COL1 | 35 | | 3 (0)| 00:00:01 | ------------------------------------------------------------------------------------------ Predicate Information (identified by operation id): --------------------------------------------------- 3 - access("COL1"=136133) 20 rows selected. Elapsed: 00:00:00.03 SYS@LAB112> SYS@LAB112> -- so the index is used as expected - does 36 lio's and completes in < 1/100 of a second SYS@LAB112> -- now let's make it do something it wouldn't normally do (with a Baseline) SYS@LAB112> -- one way is to create a Profile, create a Baseline on top, drop the Profile SYS@LAB112> SYS@LAB112> SYS@LAB112> SYS@LAB112> @create_1_hint_sql_profile Enter value for sql_id: 84q0zxfzn5u6s Enter value for profile_name (PROFILE_sqlid_MANUAL): PROFILE_84q0zxfzn5u6s_GPS Enter value for category (DEFAULT): Enter value for force_matching (false): Enter value for hint: full(skew@sel$1) Profile PROFILE_84q0zxfzn5u6s_FULL created. PL/SQL procedure successfully completed. SYS@LAB112> @avgskewi AVG(PK_COL) ----------- 15636133 Elapsed: 00:00:12.71 SYS@LAB112> SYS@LAB112> @find_sql Enter value for sql_text: Enter value for sql_id: 84q0zxfzn5u6s no rows selected Elapsed: 00:00:00.18 SYS@LAB112> SYS@LAB112> -- run again, SPM makes you run it twice ... SYS@LAB112> SYS@LAB112> @avgskewi AVG(PK_COL) ----------- 15636133 Elapsed: 00:00:07.32 SYS@LAB112> SYS@LAB112> @find_sql Enter value for sql_text: Enter value for sql_id: 84q0zxfzn5u6s SQL_ID CHILD PLAN_HASH EXECS AVG_ETIME AVG_LIO SQL_TEXT ------------- ------ ---------- ---------- ------------- ------------ ------------------------------------------------------------ 84q0zxfzn5u6s 0 568322376 1 7.31 162,301 select avg(pk_col) from kso.skew where col1 = 136133 Elapsed: 00:00:00.10 SYS@LAB112> SYS@LAB112> @dplan Enter value for sql_id: 84q0zxfzn5u6s Enter value for child_no: PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------ SQL_ID 84q0zxfzn5u6s, child number 0 ------------------------------------- select avg(pk_col) from kso.skew where col1 = 136133 Plan hash value: 568322376 --------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | --------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 28360 (100)| | | 1 | SORT AGGREGATE | | 1 | 24 | | | |* 2 | TABLE ACCESS FULL| SKEW | 35 | 840 | 28360 (1)| 00:05:41 | --------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - filter("COL1"=136133) Note ----- - SQL profile PROFILE_84q0zxfzn5u6s_FULL used for this statement 23 rows selected. Elapsed: 00:00:00.05 SYS@LAB112> SYS@LAB112> -- so it's now doing a full table scan, 162K lio's and takes several seconds SYS@LAB112> SYS@LAB112> -- now create the Baseline on the statement that's already using a Profile SYS@LAB112> SYS@LAB112> @create_baseline Enter value for sql_id: 84q0zxfzn5u6s Enter value for plan_hash_value: 568322376 Enter value for fixed (NO): Enter value for enabled (YES): Enter value for plan_name (SQL_sqlid_planhashvalue): sql_id: 84q0zxfzn5u6s plan_hash_value: 568322376 fixed: NO enabled: YES plan_name: SQL_84q0zxfzn5u6s_568322376 sql_handle: SYS_SQL_94dc89c011141f02 Baseline SQL_84q0zxfzn5u6s_568322376 created. PL/SQL procedure successfully completed. Elapsed: 00:00:00.06 SYS@LAB112> SYS@LAB112> @avgskewi AVG(PK_COL) ----------- 15636133 Elapsed: 00:00:07.44 SYS@LAB112> @avgskewi AVG(PK_COL) ----------- 15636133 Elapsed: 00:00:07.52 SYS@LAB112> SYS@LAB112> -- obviously still doing the full table scan, but let's check anyway SYS@LAB112> SYS@LAB112> @dplan Enter value for sql_id: 84q0zxfzn5u6s Enter value for child_no: PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------ SQL_ID 84q0zxfzn5u6s, child number 0 ------------------------------------- select avg(pk_col) from kso.skew where col1 = 136133 Plan hash value: 568322376 --------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | --------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 28360 (100)| | | 1 | SORT AGGREGATE | | 1 | 24 | | | |* 2 | TABLE ACCESS FULL| SKEW | 35 | 840 | 28360 (1)| 00:05:41 | --------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - filter("COL1"=136133) Note ----- - SQL profile PROFILE_84q0zxfzn5u6s_FULL used for this statement - SQL plan baseline SQL_84Q0ZXFZN5U6S_568322376 used for this statement 24 rows selected. Elapsed: 00:00:00.03 SYS@LAB112> SYS@LAB112> -- let's check hints in Profile and Baseline SYS@LAB112> SYS@LAB112> @sql_profile_hints Enter value for profile_name: PROFILE_84q0zxfzn5u6s_FULL HINT ------------------------------------------------------------------------------------------------------------------------------------------------------ full(skew@sel$1) 1 rows selected. Elapsed: 00:00:00.10 SYS@LAB112> SYS@LAB112> @baseline_hints Enter value for baseline_plan_name: SQL_84Q0ZXFZN5U6S_568322376 OUTLINE_HINTS ------------------------------------------------------------------------------------------------------------------------------------------------------ IGNORE_OPTIM_EMBEDDED_HINTS OPTIMIZER_FEATURES_ENABLE('11.2.0.1') DB_VERSION('11.2.0.1') ALL_ROWS OUTLINE_LEAF(@"SEL$1") FULL(@"SEL$1" "SKEW"@"SEL$1") 6 rows selected. Elapsed: 00:00:00.09 SYS@LAB112> SYS@LAB112> -- so the Baseline has inherited the full hint SYS@LAB112> SYS@LAB112> -- now let's drop the original Profile and add another non-standard hint to see if they are merged SYS@LAB112> SYS@LAB112> @drop_sql_profile Enter value for profile_name: PROFILE_84q0zxfzn5u6s_FULL PL/SQL procedure successfully completed. Elapsed: 00:00:00.02 SYS@LAB112> SYS@LAB112> @create_1_hint_sql_profile Enter value for sql_id: 84q0zxfzn5u6s Enter value for profile_name (PROFILE_sqlid_MANUAL): PROFILE_84q0zxfzn5u6s_GPS Enter value for category (DEFAULT): Enter value for force_matching (false): Enter value for hint: GATHER_PLAN_STATISTICS Profile PROFILE_84q0zxfzn5u6s_GPS created. PL/SQL procedure successfully completed. Elapsed: 00:00:00.05 SYS@LAB112> @avgskewi AVG(PK_COL) ----------- 15636133 1 row selected. Elapsed: 00:00:07.51 SYS@LAB112> / AVG(PK_COL) ----------- 15636133 1 row selected. Elapsed: 00:00:08.22 SYS@LAB112> SYS@LAB112> -- if that worked we should still have the full table scan from the Baseline, and the extended stats from the Profile with GATHER_PLAN_STATISTICS SYS@LAB112> SYS@LAB112> !cat dplan_allstats.sql set lines 180 select * from table(dbms_xplan.display_cursor('&sql_id','&child_no','allstats +peeked_binds')) / SYS@LAB112> @dplan_allstats Enter value for sql_id: 84q0zxfzn5u6s Enter value for child_no: PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ SQL_ID 84q0zxfzn5u6s, child number 1 ------------------------------------- select avg(pk_col) from kso.skew where col1 = 136133 Plan hash value: 568322376 ---------------------------------------------------------------------------------------------- | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads | ---------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 2 | | 2 |00:00:15.69 | 324K| 324K| | 1 | SORT AGGREGATE | | 2 | 1 | 2 |00:00:15.69 | 324K| 324K| |* 2 | TABLE ACCESS FULL| SKEW | 2 | 35 | 64 |00:00:12.02 | 324K| 324K| ---------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - filter("COL1"=136133) Note ----- - SQL profile PROFILE_84q0zxfzn5u6s_GPS used for this statement - SQL plan baseline SQL_84Q0ZXFZN5U6S_568322376 used for this statement 24 rows selected. Elapsed: 00:00:00.03 SYS@LAB112> SYS@LAB112> -- notice that the XPLAN output has A-Rows and A-Time columns - means GATHER_PLAN_STATISTICS was used SYS@LAB112> -- otherwise it would have thrown a warning message SYS@LAB112> SYS@LAB112> -- so that worked - it merged the hints! SYS@LAB112> SYS@LAB112> -- quick verify SYS@LAB112> SYS@LAB112> @sql_profile_hints Enter value for profile_name: PROFILE_84q0zxfzn5u6s_GPS HINT ------------------------------------------------------------------------------------------------------------------------------------------------------ GATHER_PLAN_STATISTICS 1 rows selected. Elapsed: 00:00:00.04 SYS@LAB112> @baseline_hints Enter value for baseline_plan_name: SQL_84Q0ZXFZN5U6S_568322376 OUTLINE_HINTS ----------------------------------------------------------------------------------------------------------------------------------------------------------- IGNORE_OPTIM_EMBEDDED_HINTS OPTIMIZER_FEATURES_ENABLE('11.2.0.1') DB_VERSION('11.2.0.1') ALL_ROWS OUTLINE_LEAF(@"SEL$1") FULL(@"SEL$1" "SKEW"@"SEL$1") 6 rows selected. Elapsed: 00:00:00.09 SYS@LAB112> SYS@LAB112> -- one more test, drop the Profile and the extended stats should go away SYS@LAB112> SYS@LAB112> @drop_sql_profile Enter value for profile_name: PROFILE_84q0zxfzn5u6s_GPS PL/SQL procedure successfully completed. Elapsed: 00:00:00.02 SYS@LAB112> @avgskewi AVG(PK_COL) ----------- 15636133 1 row selected. Elapsed: 00:00:07.20 SYS@LAB112> / AVG(PK_COL) ----------- 15636133 1 row selected. Elapsed: 00:00:07.91 SYS@LAB112> @dplan_allstats Enter value for sql_id: 84q0zxfzn5u6s Enter value for child_no: PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ SQL_ID 84q0zxfzn5u6s, child number 1 ------------------------------------- select avg(pk_col) from kso.skew where col1 = 136133 Plan hash value: 568322376 -------------------------------------------- | Id | Operation | Name | E-Rows | -------------------------------------------- | 0 | SELECT STATEMENT | | | | 1 | SORT AGGREGATE | | 1 | |* 2 | TABLE ACCESS FULL| SKEW | 35 | -------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - filter("COL1"=136133) Note ----- - SQL plan baseline SQL_84Q0ZXFZN5U6S_568322376 used for this statement - Warning: basic plan statistics not available. These are only collected when: * hint 'gather_plan_statistics' is used for the statement or * parameter 'statistics_level' is set to 'ALL', at session or system level 26 rows selected. Elapsed: 00:00:00.03 SYS@LAB112> SYS@LAB112> -- yep no more extended stats (warning message), but the full table scan is still working SYS@LAB112> SYS@LAB112> -- let's put it back the way it was SYS@LAB112> SYS@LAB112> @baselines Enter value for sql_text: Enter value for name: Enter value for plan_name: SQL_84Q0ZXFZN5U6S_568322376 SQL_HANDLE PLAN_NAME SQL_TEXT ENABLED ACC FIX LAST_EXECUTED ------------------------------ ------------------------------ -------------------------------------------------- ------- --- --- ---------------- SYS_SQL_94dc89c011141f02 SQL_84Q0ZXFZN5U6S_568322376 select avg(pk_col) from kso.skew YES YES NO 02-feb-10 20:19 1 row selected. Elapsed: 00:00:00.04 SYS@LAB112> SYS@LAB112> @drop_baseline Enter value for sql_handle: SYS_SQL_94dc89c011141f02 Enter value for plan_name: SQL_84Q0ZXFZN5U6S_568322376 PL/SQL procedure successfully completed. Elapsed: 00:00:00.01 SYS@LAB112> @avgskewi AVG(PK_COL) ----------- 15636133 1 row selected. Elapsed: 00:00:00.01 SYS@LAB112> / AVG(PK_COL) ----------- 15636133 1 row selected. Elapsed: 00:00:00.00 SYS@LAB112> @dplan_allstats Enter value for sql_id: 84q0zxfzn5u6s Enter value for child_no: PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ SQL_ID 84q0zxfzn5u6s, child number 0 ------------------------------------- select avg(pk_col) from kso.skew where col1 = 136133 Plan hash value: 3723858078 ----------------------------------------------------------- | Id | Operation | Name | E-Rows | ----------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 1 | SORT AGGREGATE | | 1 | | 2 | TABLE ACCESS BY INDEX ROWID| SKEW | 35 | |* 3 | INDEX RANGE SCAN | SKEW_COL1 | 35 | ----------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 3 - access("COL1"=136133) Note ----- - Warning: basic plan statistics not available. These are only collected when: * hint 'gather_plan_statistics' is used for the statement or * parameter 'statistics_level' is set to 'ALL', at session or system level 26 rows selected. Elapsed: 00:00:00.03 SYS@LAB112> SYS@LAB112> -- back to using the index and no stats |
As usual I used a bunch of my scripts. I believe all the scripts referenced can be found in one of these two zip files:
Controlling Execution Plans Zip File
My Favorite Scripts 2010 zip file
I have a few thoughts as to why the developers decided to implement these two features this way. Remember that SQL Profiles were designed to be generated by the SQL Tuning Advisor which does statistical analysis on a query and potentially produces hints to correct calculations that the optimizer would otherwise get wrong. So it’s possible that the developers decided they wanted these types of statistical correction hints to be combined with plans already being “enforced” by Baselines. I must say though that I don’t really think these two constructs would work well together in most cases as the hints may well end up working against each other. And since Baselines are aware of the plan they are trying to reproduce, anything that actually alters the plan would basically disable all the hints associated with the Baseline. Although I expect that the plan output would probably still say the Baseline had been used. – I haven’t tested that though – so much to do, so little time.
Last January I wrote a post with the following content:
Upgrading critical applications can be very difficult. One of the main problems is that for reasons of availability, long downtimes cannot be periodically scheduled. Therefore, for such applications, it is desirable to implement online upgrades. This requires that the application in question, as well as any software used by the application (e.g. the database engine) all support online upgrades. Oracle has recognized this problem for years. Unfortunately, up to and including Database 11g Release 1, only a limited number of features have been implemented for that purpose. As of Oracle Database 11g Release 2, this situation has changed greatly. With edition-based redefinition, Oracle Database offers real support for implementing online upgrades. The aim of the paper Edition-Based Redefinition, that I just put online here, is to provide an overview of this new feature.
I updated the aforementioned paper to provide information about the capability, as of 11.2.0.2, to specify a default edition at the service level. At the same time I added a note about the SHOW EDITION command.
Since the introduction of 11.2 I receive on a regular basis questions related to “strange” workload system statistics. The last email on that topic was sent to me yesterday. So, instead to send, again, a private reply, I decided to write this short post.
What’s wrong with 11.2 and workload system statistics?
Let’s have a look to the output of the following query:
SQL> SELECT pname, pval1 2 FROM sys.aux_stats$ 3 WHERE sname = 'SYSSTATS_MAIN'; PNAME PVAL1 --------------- ------------ CPUSPEEDNW 1596.0 IOSEEKTIM 4.0 IOTFRSPEED 4096.0 SREADTIM 10900.3 MREADTIM 4525.8 CPUSPEED 1603.0 MBRC 7.0 MAXTHR 17391616.0 SLAVETHR 413696.0
As you can see the SREADTIM and MREADTIM times are very high. In this case about three orders of magnitude of what you would expect from a regular system.
I’m not aware of the exact cause of this problem, but to me it seems that the statistics externalized in x$kcfio are broken. Anyway, in MOS there are several bugs related to it (9842771 and 9701256). Hence, it’s not a feature (e.g. a change in the unit of measure), it’s a bug. On my Linux test system I’m able to reproduce it on both 11.2.0.1 and 11.2.0.2. According to the bugs mentioned before, the problem is not limited to Linux.
Since with the DBMS_STATS package we are not able to gather correct statistics, the only advice I can give on that topic is that you have to manually set them to sensible values.
Update 2011-03-23
To fix the problem you can install the patch 9842771. It is available for 11.2.0.1 and 11.2.0.2. By the way, since the patch only provides a new version of the dbms_stats_internal package, the statistics externalized in x$kcfio are not broken… they just have another unit of measure.
Fedora 14 is here and so are the obligatory articles:
My attitude to Fedora and Ubuntu as changed today, with most of that shift due to VirtualBox.
Before I switched to VirtualBox I was always reliant on my OS being able to run VMware Server. Over the years I had repeatedly encountered problems running VMware Server on Ubuntu and Fedora. Not all of them show stoppers, but enough to put me off them as my main desktop OS. Why did I stick with VMware Server? Just because it supported shared virtual disks, which allowed me to easily create virtual RAC installations. Version 3.2.8 of VirtualBox included support for shared disks for the first time, so I ditched VMware Server and launched full scale into using VirtualBox.
While I was playing around with Fedora 14 I was thinking how cool it would be to have a newer OS on my desktop that could run Google Chrome, then it dawned on me that now I can. I’ve been free of VMware Server for a while now and I hadn’t realized the knock-on effect of that.
My years of using RHEL mean I feel a little more comfortable with Fedora than Ubuntu, but to be honest all I do on a desktop is fire up VirtualBox, use a browser (preferably Chrome) and use a terminal for SSH. Virtually everything else is done in VMs.
Now, do I waste a few days assessing the various options for my desktop, or do I just stick with CentOS and deal with the fact I can’t use Chrome on it?
Cheers
Tim…
The release 11.2.0.2 not only provides a lot of documented new features, but also provides undocumented ones. Today, I would like to spend few words about the undocumented changes introduced in the TKPROF output. In this area it is interesting to point out that after the introduction of wait events in Oracle9i, there were really few enhancement in the formatting of the output.
To show you what’s new in the output, I executed the same commands I already used in the post covering the 11.2.0.1 new features of TKPROF. I just removed the histogram on SH.SALES.CHANNEL_ID before running them (I did that because I was not interested in having different execution plans).
The relevant part of the output generated by TKPROF is the following:
SQL ID: 94mzsr37n3vz0 Plan Hash: 1550251865 SELECT * FROM sh.sales WHERE channel_id = :channel_id call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 5 0.00 0.00 0 0 0 0 Execute 5 0.00 0.00 0 0 0 0 Fetch 61263 3.58 3.65 756 69331 2 918843 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 61273 3.59 3.65 756 69331 2 918843 Misses in library cache during parse: 1 Optimizer mode: ALL_ROWS Parsing user id: 34 Rows Row Source Operation ------- --------------------------------------------------- 258025 PARTITION RANGE ALL PARTITION: 1 28 (cr=18811 pr=756 pw=0 time=664296 us cost=536 size=6661619 card=229711) 258025 TABLE ACCESS FULL SALES PARTITION: 1 28 (cr=18811 pr=756 pw=0 time=465129 us cost=536 size=6661619 card=229711)
SQL ID: 94mzsr37n3vz0 Plan Hash: 1550251865
SELECT *
FROM
sh.sales WHERE channel_id = :channel_id
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 5 0.00 0.00 0 0 0 0
Execute 5 0.00 0.00 0 0 0 0
Fetch 61263 3.58 3.65 756 69331 2 918843
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 61273 3.59 3.65 756 69331 2 918843
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 34
Number of plan statistics captured: 5
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
258025 183769 540328 PARTITION RANGE ALL PARTITION: 1 28 (cr=13866 pr=151 pw=0 time=492737 us cost=536 size=6661619 card=229711)
258025 183769 540328 TABLE ACCESS FULL SALES PARTITION: 1 28 (cr=13866 pr=151 pw=0 time=396774 us cost=536 size=6661619 card=229711)
As you can see the differences (in order or appearance, not relevance) are the following :
The new/changed information is good. But, be careful, averages hide a lot of information. So, while the new output is more useful than the old one, it’s not perfect. In fact, if you really want to know what happened at runtime, you have to give a look to the raw trace file information. In this case the information associated to the execution plans are the following (notice how the number or returned rows, attribute “cnt”, and the number of logical reads in consistent mode, attribute “cr”, changes between executions):
STAT #182927356440 id=1 cnt=258025 pid=0 pos=1 obj=0 op='PARTITION RANGE ALL PARTITION: 1 28 (cr=18811 pr=756 pw=0 time=664296 us cost=536 size=6661619 card=229711)' STAT #182927356440 id=2 cnt=258025 pid=1 pos=1 obj=13821 op='TABLE ACCESS FULL SALES PARTITION: 1 28 (cr=18811 pr=756 pw=0 time=465129 us cost=536 size=6661619 card=229711)' STAT #182927356440 id=1 cnt=540328 pid=0 pos=1 obj=0 op='PARTITION RANGE ALL PARTITION: 1 28 (cr=37596 pr=0 pw=0 time=1146677 us cost=536 size=6661619 card=229711)' STAT #182927356440 id=2 cnt=540328 pid=1 pos=1 obj=13821 op='TABLE ACCESS FULL SALES PARTITION: 1 28 (cr=37596 pr=0 pw=0 time=739039 us cost=536 size=6661619 card=229711)' STAT #182927356440 id=1 cnt=118416 pid=0 pos=1 obj=0 op='PARTITION RANGE ALL PARTITION: 1 28 (cr=9515 pr=0 pw=0 time=421391 us cost=536 size=6661619 card=229711)' STAT #182927356440 id=2 cnt=118416 pid=1 pos=1 obj=13821 op='TABLE ACCESS FULL SALES PARTITION: 1 28 (cr=9515 pr=0 pw=0 time=333077 us cost=536 size=6661619 card=229711)' STAT #182927356440 id=1 cnt=0 pid=0 pos=1 obj=0 op='PARTITION RANGE ALL PARTITION: 1 28 (cr=1635 pr=0 pw=0 time=218050 us cost=536 size=6661619 card=229711)' STAT #182927356440 id=2 cnt=0 pid=1 pos=1 obj=13821 op='TABLE ACCESS FULL SALES PARTITION: 1 28 (cr=1635 pr=0 pw=0 time=218013 us cost=536 size=6661619 card=229711)' STAT #182927356440 id=1 cnt=2074 pid=0 pos=1 obj=0 op='PARTITION RANGE ALL PARTITION: 1 28 (cr=1774 pr=0 pw=0 time=13271 us cost=536 size=6661619 card=229711)' STAT #182927356440 id=2 cnt=2074 pid=1 pos=1 obj=13821 op='TABLE ACCESS FULL SALES PARTITION: 1 28 (cr=1774 pr=0 pw=0 time=228613 us cost=536 size=6661619 card=229711)'
Another difference is related to the processing of trace files while aggregation is disabled (i.e. “aggregate=no”) and the SORT parameter is specified. The following two outputs, based on the same trace file as above, illustrate this (notice how several execution plans are displayed in the 11.2.0.1 output). Honestly, this could be seen as a bug fix.
SQL ID: 94mzsr37n3vz0
Plan Hash: 1550251865
SELECT *
FROM
sh.sales WHERE channel_id = :channel_id
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 3 0.00 0.00 0 0 0 0
Execute 3 0.00 0.00 0 0 0 0
Fetch 8037 1.01 1.02 0 12924 0 120490
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 8043 1.01 1.02 0 12924 0 120490
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 34
Rows Row Source Operation
------- ---------------------------------------------------
118416 PARTITION RANGE ALL PARTITION: 1 28 (cr=9515 pr=0 pw=0 time=421391 us cost=536 size=6661619 card=229711)
118416 TABLE ACCESS FULL SALES PARTITION: 1 28 (cr=9515 pr=0 pw=0 time=333077 us cost=536 size=6661619 card=229711)
0 PARTITION RANGE ALL PARTITION: 1 28 (cr=1635 pr=0 pw=0 time=218050 us cost=536 size=6661619 card=229711)
0 TABLE ACCESS FULL SALES PARTITION: 1 28 (cr=1635 pr=0 pw=0 time=218013 us cost=536 size=6661619 card=229711)
2074 PARTITION RANGE ALL PARTITION: 1 28 (cr=1774 pr=0 pw=0 time=13271 us cost=536 size=6661619 card=229711)
2074 TABLE ACCESS FULL SALES PARTITION: 1 28 (cr=1774 pr=0 pw=0 time=228613 us cost=536 size=6661619 card=229711)
SQL ID: 94mzsr37n3vz0 Plan Hash: 1550251865
SELECT *
FROM
sh.sales WHERE channel_id = :channel_id
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 3 0.00 0.00 0 0 0 0
Execute 3 0.00 0.00 0 0 0 0
Fetch 8037 1.01 1.02 0 12924 0 120490
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 8043 1.01 1.02 0 12924 0 120490
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 34
Number of plan statistics captured: 3
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
118416 40163 118416 PARTITION RANGE ALL PARTITION: 1 28 (cr=4308 pr=0 pw=0 time=217571 us cost=536 size=6661619 card=229711)
118416 40163 118416 TABLE ACCESS FULL SALES PARTITION: 1 28 (cr=4308 pr=0 pw=0 time=259901 us cost=536 size=6661619 card=229711)
The last thing I would like to point out, but without discussing the details, is that there are some changes in the trace files as well. The most obvious is the numbering of cursors…
While writing a post about the TKPROF new features in 11.2.0.2 I noticed that I didn’t write one about an important change introduced in 11.2.0.1. So, before finishing the other one, let’s have a look to what changed in 11.2.0.1.
One problem with TKPROF up to 11gR1 is that when the AGGREGATE parameter is set to [...]
As of 11.2.0.2 a new package, DBMS_AUTO_SQLTUNE, is available for accessing and configuring Automatic SQL Tuning. The package provides three features:
Execution of the Automatic SQL Tuning task (EXECUTE_AUTO_TUNING_TASK)
Generation of a report showing the output generated by the Automatic SQL Tuning tasks (REPORT_AUTO_TUNING_TASK)
Configuration of the Automatic SQL Tuning parameters (SET_AUTO_TUNING_TASK_PARAMETER)
In this post I would like to [...]
One year ago I wrote a post entitled Deferred Segment Creation. If you read the comments related to it you can see that several people were concerned by the fact that it was not possible to easily get rid of segments associated to empty tables. That was with version 11.2.0.1. Now we have version 11.2.0.2 [...]
Recent comments
17 weeks 5 days ago
27 weeks 3 days ago
29 weeks 1 day ago
32 weeks 2 days ago
34 weeks 4 days ago
44 weeks 1 day ago
45 weeks 5 days ago
46 weeks 5 days ago
46 weeks 6 days ago
49 weeks 4 days ago