oracle considerations
TRANSCRIPT
© 2007 Wellesley Information Services. All rights reserved.
Upgrading to Oracle 10G: CriticalDecisions for SAP AdministratorsMichael KennedySMS Consulting
2
What We’ll Cover ...
• Oracle 10G and SAP• Reorganization tips• 10G tablespace features• Database performance history and reporting• Rule-Based Optimizer (RBO)/Cost-Based Optimizer
(CBO) issues• More rollback information available• Using Oracle Flashback technology• Dropping an empty datafile• Wrap-up
3
Oracle 10G and SAP Versions
• Most Oracle/SAP customers are running on Oracle 9i with the most recent certified version of Oracle for SAP, being 9.2.0.8
• Oracle 10G release 2 (10.2.0.2) is the current certified version for SAP
• Oracle Client Software MatrixOnly use 10G Instant client for SAP Kernel 7.00 Only use 10G Instant client for BRtools 7.00Use 9.2.0.7 client for older SAP kernels and older BRtools
4
Oracle 10G and SAP Versions (cont.)
• Supported SAP versions on 10G release 2 (10.2.0.2)Generally only the SAP products in the SAP Extended Maintenance in 2007 will support Oracle 10G4.6x Kernel – SAP Note 1565486.x / 7.x Kernel – SAP Note 720886SAP releases older than 4.6x will NOT have a downward compatible release for 10G because they are not in the SAP Extended Maintenance in 2007
• SAP is currently only supporting a 9i to 10G upgrade path
• The Oracle/SAP customers on 8i should be on 8.1.7 and then upgrade to 9.2.0 and then upgrade to 10.2.
Note: Oracle Corporation does have a direct upgrade from 8.1.7 to 10G; however SAP is only supporting a 9i to 10G upgrade path
5
When to Upgrade to 10G
• Oracle 10.2.0.2 does have 21 bugfixes to apply depending on OS platform
• SAP Note 871096 makes the following reference:“Our objective is to improve the current situation (which is unsatisfactory, due to the large number of patches) as of Version 10.2.0.4, and to include all current corrections in Version 10.2.0.4. However, we cannot currently specify a date for 10.2.0.4. This note will then contain more detailed information.”
• Review SAP Note 540477 for Oracle Hot News bugfixes• Look for 10G CBO Notes for your patchset similar to the list below
because it is a good indicator that major issues have been fixed:SAP Note 981875, “Optimizer merge fix for Oracle 10.2.0.2”SAP Note 896903, “Optimizer merge fix for Oracle 9.2.0.7”SAP Note 834100, “Merge fix for Oracle 9.2.0.6”SAP Note 755629, “KKO merge fix for Oracle 9.2.0.5”
• Most performance problems with upgrades involve the CBO choosing incorrect execution plans
These CBO issues are resolved with the merge fixes for each release
6
When to Upgrade to 10G (cont.)
• In Oracle 9i, before the 10G upgrade, ensure that the 9i Oracle Universal Installer (OUI) release is at least 2.2.0.18.0 to avoid inventory corruption (see SAP Note 601965)
• Opatch automatically comes configured with 10G and does not need to be installed separately
• See SAP Note 839182 for information on Opatch• Check for INVALID objects in database before upgrade
Select object_name, object_type, status from dba_objects where status = 'INVALID';If there are invalid objects try to recompile them
$ORACLE_HOME/rdbms/admin/utlrp.sql
7
Oracle 10G Bugfixes
DescriptionNoteBugfix
10g: Corruptions with Segment Shrinking and LOBs possible1021454N/A
Optimizer merge fix for Oracle 10.2.0.2981875p5689095_10202_HPUX-IA64
Additional mergefix for Oracle 10.2.0.21002062p5667736_10202_HPUX-IA64
Wrong values when you execute parallel queries985118p5571916_10202_HPUX-IA64
ORA-07445: [$cold_qerfxArrayMaxSize()+XXXXX] 972574p5442780_10202_HPUX-IA64
Lots of ARCH trace file generated in 10.2978464p5391568_10202_HPUX-IA64
Hanging queries in Oracle 10.2.0.2 STAR_TRANSFORMATION971261p5369855_10202_HPUX-IA64
ORA-600 kdtigetrow-2 w/ array insert leads to corruptions980805p5363584_10202_HPUX-IA64
SLRAC ERRORS ARE PREVENTING DUMP OF ERRORSTACK ON INTERNAL978807p5363442_10202_HPUX-IA64
LOB corruption for NOCACHE LOBs in ASSM (ORA-1555/ORA-22924)983230p5212539_10202_HPUX-IA64
Inserts are much slower in 10.2.0.2 with unique index962859p5103126_10202_HPUX-IA64
ORA 3106 in Oracle 10.2.0.21005758p5092134_10202_HPUX-IA64
ORA-600 [kdiblLockRange:not validated] during an insert1003217p5063279_10202_HPUX-IA64
MMNL or M000 trace files on HP IA64 with Oracle 10.2.0960417p5010657_10202_HPUX-IA64
ORA-600 kcbzpbuf_1 during array insert causes corruption1013476p4899479_10202_HPUX-IA64
'cache buffer chains' in Oracle 10.2.0.21020225p4742607_10202_HPUX-IA64
Auto Space Advisor for Tablespaces Fails ORA-20000 961648p4707226_10202_HPUX-IA64
Impact of 2007 USA daylight saving (DST) changes on Oracle1019133p4689959_10202_HPUX-IA64
ORA 600 [kdtdelrow-2]1015152p4668719_10202_HPUX-IA64
Incorrect Results using a HASH GROUP BY658322p4604970_10202_HPUX-IA64
Listener Hangs841728p4518443_10202_HPUX-IA64
Example: 10.2.0.2 for HP-UX IA Bugfix Listing – Review Notes and Apply
8
10G Bugfixes
• The bugfixes may take up to 3-4 GB in the /oracle/<SID>/102_64/.patch_storage directory, see SAP Note 1026237
• Opatch makes a backup copy of the old libraries to rollback
• For 10G bugfixes the 244 mb libserver10.a is backed up multiple times
• This is an additional 3-4 gig on top of the Oracle binaries in $ORACLE_HOME, so plan accordingly
• Example:cd /oracle/SR1/102_64/.patch_storage/4668719_Nov_1_2006_03_30_57/backup/libls -l
-rw-r--r-- 1 orasr1 dba 244432196 Feb 2 06:26 libserver10.a
9
Bugfixes Applied
• In 9i and 10G, to determine which bugfixes have been applied: $ORACLE_HOME/OPatch/opatch lsinventory
Invoking OPatch 10.2.0.2.0
Oracle interim Patch Installer version 10.2.0.2.0Copyright (c) 2005, Oracle Corporation. All rights reserved.
• BRCONNECT 7.0 can show Oracle bugfixes appliedbrconnect -F lsinv
BR0801I BRCONNECT 7.00 (22)Invoking OPatch 10.2.0.2.0
Oracle interim Patch Installer version 10.2.0.2.0Copyright (c) 2005, Oracle Corporation. All rights reserved.
10
Post-Upgrade (Oracle Statistics)
• After upgrading to 10GCheck if DB02 refresh is slowA test SQL script would be:
Select segment_name, bytes from dba_extentswhere segment_name = ‘TST03’;
If the above test script takes a long time (i.e., longer than five minutes), it would appear the execution plan for DBA_EXTENTS is incorrectFollow SAP Notes 871455 and 838725 on updating the Oracle Dictionary Statistics and the X$KTFBUE table
11
Major Oracle 10G Parameters Changes
• db_file_multiblock_read_countDo not set to allow Oracle to determine the optimal number of blocks to read per fetch
Allows Oracle to use larger block fetches automaticallyOld recommendation was to set db_file_multiblock_read_count=8 in R/3Old recommendation was to set db_file_multiblock_read_count=32 in BW
• filesystemio_options=setallOld recommendation was to set to ASYNC
• optimizer_index_cost_adj =20Old recommendation was to set to 10May see a few more FULL TABLESCANS with a value of 20 compared to 10
12
Major Oracle 10G Parameters Changes (cont.)
• optimizer_mode — Do not set so Oracle will pick the default of ALL_ROWS
Old recommendation was to set optimizer_mode to CHOOSE in R/3 and BW
• recycle_bin=offDisable 10G recycle feature
• star_transformation_enabled=trueOld recommendation was set to FALSE for R/3 and must be TRUE for BW
• sga_target — Do not useWithout setting up shared_pool and db_cache minimums, sga_max_size could cause performance problems
13
New 10G Background Processes
New
AWR statistics written to diskora_mmnl_SR1AWR managerora_mmon_SR1Advanced Query Coordinatorora_qmnc_SR1Process for Advanced Queuingora_q000_SR1Distributed Transactionsora_reco_SR1Coordinates sizing of memory componentsora_mman_SR1Process for Advanced Queuingora_q001_SR1Forking new processes in MTS environmentora_psp0_SR1
System Monitor traces system resourcesora_smon_SR1Process Monitor tracks processesora_pmon_SR1Checkpoint modifies file headers ora_ckpt_SR1Log writer writes changes to redo logsora_lgwr_SR1Archive writes archive filesora_arc1_SR1Archive writes archive filesora_arc0_SR1Database writer writes dirty blocksora_dbw1_SR1Database writer writes dirty blocksora_dbw0_SR1DescriptionBackground
14
What We’ll Cover ...
• Oracle 10G and SAP• Reorganization tips• 10G tablespace features• Database performance history and reporting• Rule-Based Optimizer (RBO)/Cost-Based Optimizer
(CBO) issues• More rollback information available• Using Oracle Flashback technology• Dropping an empty datafile• Wrap-up
15
Online Segment Shrink
• HOT NEWS: As of Jan. 30, 2007, this feature may cause corruption per SAP Note 1021454; therefore do not use until a bugfix is available
• With Oracle 9i, table reorganizations are executed with: Offline methods
Export/Import ALTER TABLE MOVECreate table as SELECT
Online methodsOracle Online Table Reorg (DBMS_REDEFINITION)
Requires twice the space availableCannot reorganize LONG RAW columns (e.g., RFBLG)
Third-party online reorganization tools (e.g., Quest)
16
Online Segment Shrink (cont.)
• 10G provides Online Segment Shrink to recover free space without a reorganization
• Requirements:Requires that the tablespace is an ASSM tablespaceROW MOVEMENT must be enabled on the table, which enables Oracle to migrate rows to different Oracle blocks if needed
• Recommendation: Execute during low periods of usageLong “uncommitted” transactions will cause a TM enqueue, generally a table lock on the segment shrink command and possibly any DML statement as well
The TM lock will cause the shrink command and other DML commands to spin until the commit is completed
17
Online Segment Shrink Example
• Alter table <table_name> enable row movement• Alter table <table_name> shrink space compact
This will redistribute the rows in the partially filled blocks to free up complete blocks. The High Water Mark (HWM) does notmove, and the segment is still the same size.
• Alter table <table_name> shrink spaceThis will move the HWM and actually shrink the segment. DML can continue during the shrink command.
• Requires TM lock (DML enqueue lock), which is basically a table lock, at the end of the shrink command
18
Online Segment Shrink Example (cont.)• This example shows that the CARGO table has allocated 134 MB of storage with
87 extents. Because this is an Automatic Segment Space Management (ASSM) tablespace, the DBMS_SPACE package can be used to determine the number of blocks in each fill grade.
TABLESPACE_N SEGMENT_NAME BLOCKS BYTES EXTENTS------------ ------------ -------- ------------ ----------USERS CARGO 16,384 134,217,728 87
DBMS_SPACE.USED_SPACE
SFS1 Blocks (0-25% free) = 0 Bytes = 0FS2 Blocks (25-50% free) = 1 Bytes = 8192FS3 Blocks (50-75% free)= 0 Bytes = 0FS4 Blocks (75%-100% free)= 11792 Bytes = 96600064Full Blocks (FULL blocks) = 3912 Bytes = 32047104
• There are 11,792 Oracle blocks that have a fill grade of 75-100% (FS4) free space. Remember ASSM does not use pct_used or pct_free, but instead it uses a fill grade for each block.
19
Online Segment Shrink Example (cont.)SQL> alter table cargo enable row movement;
Table altered.
SQL> alter table cargo shrink space compact;
Table altered.
TABLESPACE_N SEGMENT_NAME BLOCKS BYTES EXTENTS------------ ------------ -------- ------------ ----------USERS CARGO 16,384 134,217,728 87
FS1 Blocks = 1 Bytes = 8192FS2 Blocks = 0 Bytes = 0FS3 Blocks = 0 Bytes = 0FS4 Blocks = 15 Bytes = 122880Full Blocks = 3910 Bytes = 32030720
• After the SHRINK SPACE COMPACT command, notice the number of blocks with a fill of 75-100% free has reduced from 11,792 to 15 as the rows are migrated to completely fill up the blocks.
• The total size of the table has not changed because the “shrink space compact” only migrates the rows.
20
Online Segment Shrink Example (cont.)SQL> alter table cargo shrink space;
Table altered.
TABLESPACE_N SEGMENT_NAME BLOCKS BYTES EXTENTS
------------ ------------ -------- ------------ ----------USERS CARGO 4,184 34,275,328 48
FS1 Blocks = 0 Bytes = 0FS2 Blocks = 0 Bytes = 0
FS3 Blocks = 0 Bytes = 0FS4 Blocks = 195 Bytes = 1597440Full Blocks = 3911 Bytes = 32038912
• After the “Shrink Space” command, the size of the table has been reduced from 134 MB to 34 MB.
21
Bitmap Index Rebuild Online• Oracle 9i does not allow bitmap index rebuilds online
alter index bitmap_test_9i_0 rebuild online*ERROR at line 1:ORA-08108: may not build or rebuild this type of index online
• Starting with 10G, bitmap indexes can be rebuilt online
INDEX_NAME INDEX_TYPE------------------------------ ---------------------------BITMAP_TEST_0 BITMAP
SQL> alter index BITMAP_TEST_0 rebuild online;
Index altered.
22
Bitmap Index Rebuild Online (cont.)• Wait event if a DML is started BEFORE the REBULD and no commit
SID EVENT P1 P2 P3 SECONDS_IN_WAIT
--- ---------------------------- ---------- ---------- ---------- ---------------312 index (re)build online start 127658 4 0 226
• Wait event if DML happens during the index rebuild online
SID EVENT P1 P2 P3 SECONDS_IN_WAIT---------- ----------------------------------- ---------- ---------- ---------- ---------------
312 index (re)build online merge 127658 4 0 87
• BRSPACE does NOT have an ONLINE option for Online Bitmap Index rebuild
• BRSPACE options for rebuild of indexes:
1 - BRSPACE profile (profile) ...... [initSR1.sap]2 - Database user/password (user) .. [saprtl/********]3 - Rebuild action (action) ........ [rebuild]4 - Tablespace names (tablespace) .. []5 - Index owner (owner) ............ [saprtl]6 - Table names (table) ............ []7 - Index names (index) ............ [bitmap_test_0]8 - Confirmation mode (confirm) .... [yes]9 - Extended output (output) ....... [no]10 - Scrolling line count (scroll) .. [20]11 - Message language (language) .... [E]12 - BRSPACE command line (command) . [-p initSR1.sap -s 20 -l E -f idrebuild -a rebuild -o saprtl -i
“bitmap_test_0”]
23
Long to Large Object (LOB) Migration
• Online table reorganization is possible starting with 9.2 (recommended 9.2.0.6 per Note 646681)
• Oracle 9i cannot reorganize tables online with LONG or LONG RAW column definitions using the DBMS_REDEFINITION package
However, by converting the tables with LONG columns to an LOB, the table can then be reorganized online
• BRSPACE can convert the LONG to LOB as long as the SAP Kernel is at 6.40 or higher
• Note 835552 recommends that if there is no technical reason, do not migrate and continue to use the LONG column definitions
24
Long to Large Object (LOB) Migration (cont.)
SQL> desc ATAB_LOBName Null? Type----------------------------------------- -------- ----------------------------TABNAME NOT NULL VARCHAR2(30)VARKEY NOT NULL VARCHAR2(150)DATALN NOT NULL NUMBER(5)VARDATA LONG RAW
• BRSPACE options for reorganization of tables:
1 - BRSPACE profile (profile) ...... [initSR1.sap]2 - Database user/password (user) .. [saprtl/********]3 - Reorganization action (action) . [long2lob]4 - Tablespace names (tablespace) .. [psaprtl]5 - Table owner (owner) ............ [saprtl]6 - Table names (table) ............ [atab_lob]7 - Confirmation mode (confirm) .... [yes]8 - Extended output (output) ....... [no]9 - Scrolling line count (scroll) .. [20]10 - Message language (language) .... [E]11 - BRSPACE command line (command) . [-p initSR1.sap -s 20 -l E -f tbreorg -a long2lob -s psaprtl -o saprtl -t
“atab_lob”]
25
Long to Large Object (LOB) Migration
• BRTOOLS uses Oracle Materialized Views to do the ONLINE migration, as seen here
BEGIN DBMS_REDEFINITION.START_REDEF_TABLE ('"SAPRTL"', '"ATAB_LOB"', '"ATAB_LOB#$"', '"TABNAME" "TABNAME", "VARKEY" "VARKEY", "DATALN" "DATALN", TO_LOB("VARDATA") "VARDATA"', DBMS_REDEFINITION.CONS_USE_ROWID); END;#
SQL> desc atab_lob
Name Null? Type
----------------------------------------- -------- ----------------------------
TABNAME NOT NULL VARCHAR2(30)
VARKEY NOT NULL VARCHAR2(150)
DATALN NOT NULL NUMBER(5)
VARDATA BLOB
26
Long to Large Object (LOB) Migration (cont.)
• According to SAP Notes 835552, 838725, and 646681, a LOB may be 30% slower on DML
• This may not be a noticeable slowdown with users using fast lookup transactions, but long running jobs that do large DML over a long time (i.e. MRP) may be slower
• The decision to migrate LONG to LOB definitions may depend on the customer’s need for online reorganizations versus the need for performance
• If the tables do not need to be reorganized frequently, then no migration is needed
• If tables need to be reorganized frequently, then a migration may need to be considered
27
What We’ll Cover ...
• Oracle 10G and SAP• Reorganization tips• 10G tablespace features• Database performance history and reporting• Rule-Based Optimizer (RBO)/Cost-Based Optimizer
(CBO) issues• More rollback information available• Using Oracle Flashback technology• Dropping an empty datafile• Wrap-up
28
Renaming Tablespaces
• What’s the problem with doing reorgs in the database? Having to move the objects to another tablespace!
Then you have to update the SAP Data Dictionary • 10G provides the ability to rename the tablespace
29
Renaming a Tablespace Examplecreate tablespace psap_renamedatafile 'D:\ORACLE\ORADATA\G10\PSAP_RENAME.DBF' size 5M;
Tablespace created.
alter user sapr3 default tablespace psap_rename;
User altered.
alter tablespace psap_rename rename to psapbtabd;
Tablespace altered.
select username, default_tablespace from dba_userswhere username = 'SAPR3';
USERNAME DEFAULT_TABLESPACE------------------------------ ------------------------------SAPR3 PSAPBTABD
30
Renaming a Tablespace Example (cont.)
• BRSPACE options for alter tablespace:1 - BRSPACE profile (profile) ........ [initSR1.sap]2 - Database user/password (user) .... [saprtl/********]3 - Alter tablespace action (action) . [rename]4 - Tablespace names (tablespace) .... [psap_rename]5 - Confirmation mode (confirm) ...... [yes]6 - Scrolling line count (scroll) .... [20]7 - Message language (language) ...... [E]8 - BRSPACE command line (command) ... [-p initSR1.sap -s 20 -l E -f tsalter -a rename
-t psap_rename]• Options for alter of tablespace PSAP_RENAME:
1 - Current tablespace status (status) . [ONLINE]2 - Current backup status (backup) ..... [NO]3 - Alter tablespace action (action) ... [rename]4 - Set offline mode (mode) ............ [normal]5 - New tablespace name (name) ......... [PSAPBTABD]6 - Force tablespace alter (force) ..... [no]7 - SQL command (command) .............. [alter tablespace PSAP_RENAME rename to PSAPBTABD]
31
SYSAUX Tablespace
• There is a new tablespace called SYSAUX• SYSAUX is mandatory • Created as Automatic Segment Space Management
(ASSM) autoextend• Holds metadata outside the SYSTEM tablespace
32
SYSAUX Tablespace (cont.)
• Main components stored in SYSAUX instead of SYSTEMLog MinerAutomatic Workload Repository (AWR)Optimizer statisticsStatspack information
• SYSAUX is VERY important to the database functioning properly!
• Holds AWR data for a default of seven days so size should stabilize after then
33
V$SYSAUX_OCCUPANTS
• Shows products installed in the SYSAUX tablespace and the space used
34
New PSAPSAUX Tablespace
• Create a new PSAPAUX default tablespace following SAP Note 969674
• This tablespace will be where the default tables and indexes go• Brtools 7.00 patch level 20 will detect the creation of PSAPSAUX
and change the default tablespaces automatically• Example Brtools creating PSAPAUX
BR1016I SQL statement 'create tablespace PSAPSAUX extent management local autoallocate datafile '/oracle/SR1/sapdata1/saux_1/saux.data1' size 20M autoextend on next 100M maxsize 500M' executed successfullyBR1060I Tablespace PSAPSAUX created successfully with file: /oracle/SR1/sapdata1/saux_1/saux.data1 20M
BR0280I BRSPACE time stamp: 2007-02-13 19.32.29BR1235I The default permanent tablespace of database SR1 can be set to PSAPSAUX nowBR0675I Do you want to perform this action?BR0676I Enter 'y[es]/c[ont]' to perform the action, 'n[o]' to skip it, 's[top]' to abort:yes
35
New PSAPSAUX Tablespaceselect username, DEFAULT_TABLESPACE, TEMPORARY_TABLESPACE from dba_users;
USERNAME DEFAULT_TABLESPACE TEMPORARY_TABLESPACE
--------------- -------------------- --------------------
SYSTEM SYSTEM PSAPTEMP
SYS SYSTEM PSAPTEMP
SAPDR2DB PSAPDR2DB PSAPTEMP
DIP PSAPSAUX PSAPTEMP
OPS$SR1ADM PSAPSAUX PSAPTEMP
SAPRTL PSAPRTLUSR PSAPTEMP
TSMSYS PSAPSAUX PSAPTEMP
DBSNMP PSAPSAUX PSAPTEMP
OUTLN SYSTEM PSAPTEMP
36
What We’ll Cover ...
• Oracle 10G and SAP• Reorganization tips• 10G tablespace features• Database performance history and reporting• Rule-Based Optimizer (RBO)/Cost-Based Optimizer
(CBO) issues• More rollback information available• Using Oracle Flashback technology• Dropping an empty datafile• Wrap-up
37
Automatic Workload Repository (AWR)
• AWR replaces Oracle STATSPACK and provides a repository to store performance and history information
• Every hour a snapshot of the database is taken automatically and stored in the repository
• The AWR holds data for seven days (default), which can be customized and seen in the view DBA_HIST_WR_CONTROL
• Created using $ORACLE_HOME/rdbms/admin/awrrpt.sql
38
AWR Report Example
39
Automatic Workload Repository (AWR)
• 10G now provides different DBA_HIST viewsDBA_HIST_FILESTATXS: Data file accessesDBA_HIST_TEMPSTATXS: Tempfile accessesDBA_HIST_SYSTEM_EVENT: Accumulated wait eventsDBA_HIST_WAITSTAT: Buffer busy waitsDBA_HIST_ENQUEUE_STATS: Enqueue waitsDBA_HIST_LATCH: Latch waitsDBA_HIST_SYSSTAT: System-wide statistical informationDBA_HIST_ACTIVE_SESS_HISTORY: Snapshots of the wait events of active sessions
40
ADDM
• ADDM uses the DBA_HIST views in the Automatic Workload Repository to report the performance characteristics of the database
• Running $ORACLE_HOME/rdbms/admin/addmrpt provides a report
• Replaces Oracle Statspack (SAP Note 717484)• Can be used with Oracle Tuning Pack and the Oracle
Diagnostics PackIf your Oracle license is purchased through SAP, these features are already licensed with SAP and can be usedSAP will NOT support the use or issues of the Oracle Tuning and Diagnostic Packs but this does not invalidate SAP’s support of the system
41
Example Output of an ADDM Report:
42
Automatic Session History (ASH)
• ASH shows a history of session waits See SAP Note 853576
• ASH uses the new DBA_HIST views to maintain history• Can be run from
$ORACLE_HOME/rdbms/admin/ashrpt.sql
43
ASH Example
44
Automatic Segment Advisor (ASA)
• ASA monitors table and index usage• May need to be disabled per SAP Note 974781 due to
high database load• Recommended ASA usage if enabled:
In the Enterprise ManagerIn the following AWR database tables:
DBA_ADVISOR_RECOMMENDATIONSDBA_ADVISOR_FINDINGSDBA_ADVISOR_ACTIONSDBA_ADVISOR_OBJECTS
Use DBMS_SPACE.ASA_RECOMMENDATIONS procedure
45
Notes for 10G Monitoring
• In 10G, Oracle will automatically gather statistics SAP only supports BRCONNECT statistics gatheringTherefore disable the automatic Oracle job GATHER_STATS_JOB (SAP Note 974781)
Execute dbms_scheduler.disable('GATHER_STATS_JOB');• Some of the new 10G monitor features require a licensed
Oracle Diagnostic and Tuning Pack (SAP Note 853576)• If you plan NOT to install the Oracle Diagnostic and
Tuning pack, then disable ASA until needed: Disable the Automatic Segment Advisor job due to high resource consuming SQL (SAP Note 927813)
EXEC DBMS_SCHEDULER.DISABLE('AUTO_SPACE_ADVISOR_JOB');
46
Notes for 10G Monitoring (cont.)• The following SQL will show which 10G component takes the most space in the
SYSAUX tablespace:SELECT * FROM( SELECT
OCCUPANT_DESC,SPACE_USAGE_KBYTES
FROMV$SYSAUX_OCCUPANTS
ORDER BYSPACE_USAGE_KBYTES DESC)
WHERE ROWNUM <=10/
OCCUPANT_DESC SPACE_USAGE_KBYTES---------------------------------------------------------------- ------------------Server Manageability - Automatic Workload Repository 38144Server Manageability - Optimizer Statistics History 25920Server Manageability - Advisor Framework 15488LogMiner 6016Server Manageability - Other Components 4928Logical Standby 896Analytical Workspace Object Table 768OLAP API History Tables 768Oracle Streams 512Unified Job Scheduler 384
10 rows selected.
47
What We’ll Cover ...
• Oracle 10G and SAP• Reorganization tips• 10G tablespace features• Database performance history and reporting• Rule-Based Optimizer (RBO)/Cost-Based Optimizer
(CBO) issues• More rollback information available• Using Oracle Flashback technology• Dropping an empty datafile• Wrap-up
48
RBO/CBO Issues
• Starting with Oracle 10G, the Rule-Based Optimizer (RBO) is considered an unsupported feature; this means no new development will be done on the RBO per Oracle Metalink Note 189702.1
• The RBO still exists and functions in 10G, but only as an unsupported feature; therefore, applications should start migrating to the Cost-Based Optimizer (CBO)
• The Rule HINT is de-supported, see SAP Note 826635
GOTCHA!
49
CBO — Dynamic Sampling
• Below is a query on RFBLG from a 9i database
• Notice that RBO is used — there are NO statistics!
50
CBO — Dynamic Sampling (cont.)
• Below is the same query on RFBLG from a 10G database
• Notice the CBO is used due to COST calculation. Why?
51
CBO — Dynamic Sampling (cont.)
• As shown, the CBO is automatically generating a COST calculation when the table has NO statistics
• How does Oracle generate Dynamic Sampling?Optimizer_dynamic_sampling =2 (default)
Per 10.2 Oracle Performance Tuning Documentation chapter 14, the levels for the optimizer_dynamic_sampling are:
Level 0: Do not use dynamic samplingLevel 1: The number of blocks sampled is the default number of dynamic sampling blocks (32)Levels 2, 3, 4, 5, 6, 7, 8, and 9: The number of blocks sampled is 2, 4, 8, 16, 32, 64, 128, or 256 times the default number of dynamic sampling blocks respectivelyLevel 10: Read all blocks in the table
52
CBO — Dynamic Sampling (cont.)
• How does Oracle generate Dynamic Sampling?Optimizer_features_enabled =10.2.0.2
If set to 9.2.0, this feature is disabledThe CBO will issue a SAMPLING SQL statement to sample 2*default blocks (32) on the table, as shown below, to get dynamic statistics
SELECT /* OPT_DYN_SAMP */ /*+ ALL_ROWS IGNORE_WHERE_CLAUSE NO_PARALLEL(SAMPLESUB) opt_param('parallel_execution_enabled', 'false') NO_PARALLEL_INDEX(SAMPLESUB) NO_SQL_TUNE */ NVL(SUM(C1),:"SYS_B_0"), NVL(SUM(C2),:"SYS_B_1") FROM (SELECT /*+ NO_PARALLEL("RFBLG") FULL("RFBLG") NO_PARALLEL_INDEX("RFBLG") */ :"SYS_B_2" AS C1, :"SYS_B_3" AS C2 FROM "RFBLG“ SAMPLE BLOCK (:"SYS_B_4" , :"SYS_B_5") SEED (:"SYS_B_6") "RFBLG") SAMPLESU
53
CBO — Dynamic Sampling: Rules of Thumb
• If confused by explain plan, check to see if table has statistics
• Check tables that do not have generated statistics withSelect table_name, last_analyzed, num_rows from dba_tables where last_analyzed is null;
• If the table has statistics, then dynamic sampling will not be used
• Dynamic sampling is controlled by the parameter optimizer_dynamic_sampling which has a default value of two
The default value of two means Oracle will dynamically sample 2 * 32 blocks, for a total of 64 blocks
54
What We’ll Cover ...
• Oracle 10G and SAP• Reorganization tips• 10G tablespace features• Database performance history and reporting• Rule-Based Optimizer (RBO)/Cost-Based Optimizer
(CBO) issues• More rollback information available• Using Oracle Flashback technology• Dropping an empty datafile• Wrap-up
55
Better Rollback Information
• For long-running transactions, we used to use v$transaction and the columns used_urec and used_ublkto “guess” how long it takes a long-running transaction to rollback:
select addr, used_urec, used_ublk fromv$transactionADDR USED_UREC USED_UBLK-------- ---------- ----------19655F64 524284 4263
56
Better Rollback Information (cont.)insert into cargo select * from cargo;
1048576 rows created.
1* select used_urec , used_ublk from v$transaction
USED_UREC USED_UBLK---------- ----------
1048576 8526
57
V$SESSION_LONGOPS
58
V$SQL
• The column SQL_ID has been added to V$SQL• DBAs can now use the SQL_ID column from v$session_longops to
find the running SQL statement via V$SQL
select sql_text from v$sql where sql_id = '18grqd4nfgv98‘
SQL_TEXT---------------------------------------------------------Rollback
59
What We’ll Cover ...
• Oracle 10G and SAP• Reorganization tips• 10G tablespace features• Database performance history and reporting• Rule-Based Optimizer (RBO)/Cost-Based Optimizer
(CBO) issues• More rollback information available• Using Oracle Flashback technology• Dropping an empty datafile• Wrap-up
60
Oracle Flashback Query Feature
• In Oracle 9i, Flashback Query was able to recover deleted rows from a table by using the data still stored in the rollback/undo segments to a point in time
• The amount of data that can be flashed back depends on the undo_retention parameter because changed data will possibly be held in the rollback/undo for that timeframe
61
Oracle Flashback Query (Example)
SQL> create table flashback (t1 number, time date);
Table created.
SQL> insert into flashback values (1, sysdate);
1 row created.
SQL> insert into flashback values (2, sysdate);
1 row created.
SQL> commit;
Commit complete.
62
Oracle Flashback Query (Example) (cont.)
SQL> delete from flashback;
2 rows deleted.
SQL> commit;
Commit complete.
SQL> select * from flashback;
no rows selected
63
Oracle Flashback Query (Example) (cont.)
• Option # 1: Create the table based on Timecreate table flashback_orig as select * from flashbackas of timestamp to_timestamp('12.02.2007:20:18:00','dd.mm.yyyy:hh24:mi:ss')
• Option # 2: Create the table based on SCNselect to_char(time_dp,'dd.mm.yyyy:hh24:mi:ss') time, scn_basfrom sys.smon_scn_time order by time_dp desc
TIME SCN_BAS
------------------- ----------
12.02.2007:20:40:32 599096
12.02.2007:20:35:08 598866
12.02.2007:20:30:26 598731
12.02.2007:20:25:03 598454
12.02.2007:20:20:32 598306
12.02.2007:20:15:08 598126
12.02.2007:20:10:29 597979
64
Oracle Flashback Query (Example) (cont.)SQL> create table flashback_orig as select * from flashback as of scn 598200;
Table created.
SQL> select * from flashback_orig;
T1 TIME
---------- ---------
1 12-FEB-07
2 12-FEB-07
65
Flashback Table
• Recovering a dropped table is possible in 10G, but is not supported by SAP at this time
SAP disables the recyclebin feature on upgrade
66
Flashback Table (cont.)
• SAP does NOT support this feature “yet”• When you upgrade to 10G, the instructions are to disable
the recycle bin (see SAP Note 838982)
67
What We’ll Cover ...
• Oracle 10G and SAP• Reorganization tips• 10G tablespace features• Database performance history and reporting• Rule-Based Optimizer (RBO)/Cost-Based Optimizer
(CBO) issues• More rollback information available• Using Oracle Flashback technology• Dropping an empty datafile• Wrap-up
68
Dropping an Empty Datafile
• SyntaxALTER TABLESPACE <tsp_name> DROP DATAFILE '<path_and_name>';
• Examplealter tablespace PSAPTEST drop datafile 'C:\ORACLEXE\ORADATA\XE\PSAPTEST1.DBF';
• If there is an object residing in the datafile that is being dropped, Oracle will issue an “ORA-03262: the file is non-empty” error
69
What We’ll Cover ...
• Oracle 10G and SAP• Reorganization tips• 10G tablespace features• Database performance history and reporting• Rule-Based Optimizer (RBO)/Cost-Based Optimizer
(CBO) issues• More rollback information available• Using Oracle Flashback technology• Dropping an empty datafile• Wrap-up
70
Resources
• Oracle/SAP Newsletterwww.oracle.com/newsletters/sap/current.html
• Oracle Segment Shrink SAP Note 910389
http://service.sap.com/notes*• RBO Desupport Notice for 10G
SAP Note 804415Metalink Note 189702.1 www.metalink.oracle.com
• Oracle 9i and 10G Desupport NoticesMetalink Note 161818.1www.metalink.oracle.com
• Oracle Recycle Bin Disabled for SAP CustomersSee SAP Note 838982http://service.sap.com/notes*
* Requires login credentials to the SAP Service Marketplace
71
Resources (cont.)
• Basic Oracle Performance AnalysisSee SAP Notes 618868, 619188, 766349http://service.sap.com/notes*
• Information on 10G Instant ClientSAP Note 819829http://service.sap.com/notes*
• 10G SAP Segment AdviserNote 927813http://service.sap.com/notes*
• 10G Segment ShrinkSAP Note 910389
Patches are required due to corruptionhttp://service.sap.com/notes*Oracle Metalink Note 242090.1
www.metalink.oracle.com* Requires login credentials to the SAP Service Marketplace
72
7 Key Points to Take Home
• Start testing 10G now• Wait at least three months between patchsets before
moving to production• Look for the 10G CBO Merge Fix note and monitor any
SAP Notes involving the 10G CBO• Attempt to comply with Oracle/SAP standards:
ASSM tablespacesAutomatic Undo Management (AUM) — RollbackAutomatic PGASPFILEDefault temporary tablespace
73
7 Key Points to Take Home (cont.)
• Become familiar with Oracle’s AWR and ADDM to report performance and history
• Review any custom ABAP that uses the RULE hint and test with CBO
• Determine if LONG to LOB migration is needed for reorganization purposes