Subscribe to Posts by Email

Subscriber Count

    705

Disclaimer

All information is offered in good faith and in the hope that it may be of use for educational purpose and for Database community purpose, but is not guaranteed to be correct, up to date or suitable for any particular purpose. db.geeksinsight.com accepts no liability in respect of this information or its use. This site is independent of and does not represent Oracle Corporation in any way. Oracle does not officially sponsor, approve, or endorse this site or its content and if notify any such I am happy to remove. Product and company names mentioned in this website may be the trademarks of their respective owners and published here for informational purpose only. This is my personal blog. The views expressed on these pages are mine and learnt from other blogs and bloggers and to enhance and support the DBA community and this web blog does not represent the thoughts, intentions, plans or strategies of my current employer nor the Oracle and its affiliates or any other companies. And this website does not offer or take profit for providing these content and this is purely non-profit and for educational purpose only. If you see any issues with Content and copy write issues, I am happy to remove if you notify me. Contact Geek DBA Team, via geeksinsights@gmail.com

Pages

Debate: SPA vs. SPM vs. ACS, SPM vs. sql_profiles etc.

Well there are many sources to explain about the functionality of

  • SQL Stored Outlines
  • SQL Profiles
  • SQL Performance Analyzer
  • Adaptive Cursor Sharing
  • SQL Plan Management

Indeed all these tools are available to give the plan stability but with different ways.

Basics:- Plan instability can occur due to bind value differences. Binds are used to reduce the hard parsing when application is using same statement.

Oracle introduced the bind peeking feature in Oracle 9i. With bind peeking, the Optimizer peeks at the values of user-defined bind variables on the first invocation of a cursor. This allows the optimizer to determine the selectivity of any WHERE clause condition as if literals have been used instead of bind variables, thus improving the quality of the execution plan generated for statements using bind variables.

However, there was a problem with this approach, when the column used in the WHERE clause with the bind contained a data skew. If there is data skew in the column, it is likely that a histogram has been created on this column during statistics gathering. When the optimizer peeks at the value of the user-defined bind variable and chooses a plan, it is not guaranteed that this plan will be good for all possible values for the bind variable. In other words, the plan is optimized for the peeked value of the bind variable, but not for all possible values.

The optimizer has been further enhanced in 11g to allow multiple execution plans to be used for a single statement that uses bind variables. This ensures that the best execution plan will be used depending on the bind value.

So with above changes from 9i to 11g, Oracle comes with plan stability with different set of

Continue reading Debate: SPA vs. SPM vs. ACS, SPM vs. sql_profiles etc.

Scripts: Finding the object or statement that is causing excessive redo generation

How to find the object that is causing excessive redo or archive generation between a given date. You can get from the v$log_history but for history you will need to query the awr history views as below.

SELECT dhso.object_name,
sum(db_block_changes_delta)
FROM dba_hist_seg_stat dhss,
dba_hist_seg_stat_obj dhso,
dba_hist_snapshot dhs
Continue reading Scripts: Finding the object or statement that is causing excessive redo generation

ORA-00376: file xx cannot be read at this time, undo corruption

All of the actions below are performed after careful analysis, any act of below in business critical system may cause serious implications.

Issue : Undo lob corruption in one of the database.

Ironically, the DB is in no archive log mode and no backup exist.

Verify is it block corruption using db verify.

XXXXXX:TEST1:UAT $ dbv FILE='/u04/oradata/TEST1/datafile/undotbs1_01.dbf' Continue reading ORA-00376: file xx cannot be read at this time, undo corruption

Quiz Post #7: Get sql trace without reexecuting it – 11g DBMS_SQLDIAG

In general you will need to set the SQL trace or events (10046,10053) and run the problematic query and can obtain the sql execution statistics to trace files.

or Continue reading Quiz Post #7: Get sql trace without reexecuting it – 11g DBMS_SQLDIAG

11g SQL Monitoring: Real Time sql monitoring

All,

I have got a chance to speak about this nice cool feature in an other practical demo session to my colleagues, but few questions on the same remind to post and read something on this.

Typically as usual my post flow, What, How, How to, Important note?

What is SQL Monitoring?

If a query is a “long” query, if it uses more than 5 seconds of CPU of I/O Wait or if it’s a parallel query (from the documentation), the plan execution statistics are kept by the engine and you can follow the query execution in Real Time.

How does it Work?

Once monitoring is initiated, an entry is added to the dynamic performance view V$SQL_MONITOR. To uniquely identify two executions of the same SQL statement, a composite key called an execution key is generated. This execution key is composed of three attributes, each corresponding to a column in V$SQL_MONITOR:

  • SQL identifier to identify the SQL statement (SQL_ID)

  • Start execution timestamp (SQL_EXEC_START)

  • An internally generated identifier to ensure that this primary key is truly unique (SQL_EXEC_ID)

How to make use of it? Different ways?

Continue reading 11g SQL Monitoring: Real Time sql monitoring

Performance Tuning: Oracle Top Wait events, Causes, Resolutions

Hello,

In case you want to know more about Oracle Wait events please read here

What are the causes for those wait event and how you can troubleshoot and resolve the same was neatly written in this document.

This document is very good, structured (apologies I do not remember the source and who written it,  downloaded sometime back), neatly written which may useful for you all.

http://db.geeksinsight.com/wp-content/uploads//2012/10/resolving-common-oracle-wait-events-using-the-wait-interface.doc

 

-Thanks

Geek DBA

Dynamic Sampling: Use,Levels,10g-11g behavior,

We all know that Oracle Optimizer use object statistics to determine the cost of accessing that object. What if, if that object has missed statistics or the columns or the

Hence Oracle introduced Dynamic sampling in 9i and has changed significantly through 11g.

Definition:-

Dynamic sampling augments missing or insufficient optimizer statistics. Using dynamic sampling the optimizer can improve plans by making better estimates for predicate selectivity. Dynamic sampling can supplement statistics such as table block counts, applicable index block counts, table cardinalities (estimated number of rows), and relevant join column statistics.

To make use of it:-

Dynamic sampling is enabled in the database by default (level 2). You can disable the feature by setting the initialization parameter OPTIMIZER_DYNAMIC_SAMPLING=0.

Dynamic Sampling Levels:-

Continue reading Dynamic Sampling: Use,Levels,10g-11g behavior,

Cardinality Feedback: What is it? When it will be used? 10g vs 11g

What is cardinality?

CBO estimate of the number of rows produced by a row source or combination of row sources.

What are different types of cardinality?

Cardinality

Cardinality represents the number of rows in a row set. Here, the row set can be a base table, a view, or the result of a join or GROUP BY operator.

  • Base cardinality is the number of rows in a base table. The base cardinality can be captured by analyzing the table. If table statistics are not available, then the estimator uses the number of extents occupied by the table to estimate the base cardinality.
  • Effective cardinality is the number of rows that are selected from a base table. The effective cardinality depends on the predicates specified on different columns of a base table, with each predicate acting as a successive filter on the rows of the base table. The effective cardinality is computed as the product of the base cardinality and combined selectivity of all predicates specified on a table. When there is no predicate on a table, its effective cardinality equals its base cardinality. Continue reading Cardinality Feedback: What is it? When it will be used? 10g vs 11g

12c Database: OOW Updates

The following may appear in the upcoming release Oracle 12c database.

Architecture in 12c: Multitenant Database , container CDB.

Indexing in 12c: Allows multiple index on same column definition , appealing but not confirmed yet.

Partitioning in 12c: Online move of partition, multiple partition merge in one go, partial indexing, interval reference partitioning

Identity columns in 12c: Attached to primary keys and auto incremented as it grows.

Archive Log Compression: Yes, it appears in metalink, Archive log compression with “ALTER DATABASE ARCHIVELOG COMPRESS enable;"

I Will keep adding as and when I see/heard something new from others or documentation.

-Thanks

Geek DBA

SQL Performance Analyzer: Compare two workloads using DBMS_SPA

Hello,

The following Sql performance analyzer procedure helps you to create a comparison report of multiple runs.

This will especially useful when there is a major change in application for example: Application release, or Database optimizer settings changes etc.

**************************************************************************************

Step 1: Adjust the snapshot collection interval accordingly to 15 mins, the default is 30 mins.

    SQL> exec dbms_workload_repository.modify_snapshot_settings (interval => 15);


**************************************************************************************

Step 2: Create a Manual snapshot and note down the snap ID

SQL> EXEC DBMS_WORKLOAD_REPOSITORY.create_snapshot;
SQL> select max(snap_id) from dba_hist_snapshot;

**************************************************************************************

Step 3: Ask App team to run RUN the load or assuming you are testing with optimizer features enable parameter = 10.2.0.4 or 9.2.0.8

alter session set optimizer_features_enable='9.2.0.8';

and Ask to run the load

**************************************************************************************

Note:- Two choices if you want to load from Cache use Step 4a, If you want to use AWR repository for sql tuning set  use step 4b.

******************************************************************************

Step 4a: From Buffer Cache
****************************************************************************
   

DECLARE
cur1 DBMS_SQLTUNE.SQLSET_CURSOR;
cur2 DBMS_SQLTUNE.SQLSET_CURSOR;
h1 NUMBER ;
v_schema_name VARCHAR2(30) := '&1' ;
v_tablespace_name VARCHAR2(30) := 'USERS'
v_table_name VARCHAR2(10) := '&2' ;
v_sts_name VARCHAR2(10) := '&3' ;
v_logfile VARCHAR2(30) ;
v_dumpfile VARCHAR2(100) ;
v_export_name VARCHAR2(30) ;
v_condition VARCHAR2(100) ;
v_beginsnap number;:= &4;
v_endsnap number;:= &5;
BEGIN
v_logfile := v_schema_name || '_' || v_sts_name || '_' || to_char(SYSDATE,'yyyymmdd') || '.dmp.log' ;
v_dumpfile := v_schema_name || '_' || v_sts_name || '_' || to_char(SYSDATE,'yyyymmdd') || '.dmp.log' ;
v_export_name := 'STS_' || v_sts_name || '_' || to_char(SYSDATE,'yyyymmdd') ;
v_condition := 'parsing_schema_name <> ' || '''' || 'SYS' || '''' || ' AND (sql_text like ' || '''' || 'SELECT%' || '''' || ' or sql_text like ' || '''' || 'select%' || '''' || ') ' ;
-- Create the sql set
DBMS_OUTPUT.PUT_LINE ('Creating SQL Tuning Set') ;

        DBMS_SQLTUNE.CREATE_SQLSET(sqlset_name => v_sts_name, sqlset_owner=> v_schema_name);
-- open cursor of our sql to load into the tuning set
OPEN cur1 FOR
SELECT VALUE(P)
FROM table(DBMS_SQLTUNE.SELECT_CURSOR_CACHE(v_condition, NULL, NULL, NULL, NULL, 1, NULL, 'ALL')) P;
DBMS_OUTPUT.PUT_LINE ('Loading Buffer Cache Data into SQL Tuning Set') ;
DBMS_SQLTUNE.LOAD_SQLSET(sqlset_name => v_sts_name, populate_cursor => cur1, sqlset_owner=> v_schema_name);
CLOSE cur1 ;

    END ;
/

**************************************************************************************

Step 4b: From AWR :

****************************************************************************

 The following block will ask to provide
schema name -> Parsing schema name i.e App schema
Tablename -> staging tablename
Tuningset name -> name ideally "Parellel1"
beginsnap -> generated at step 1
end snap -> generated at this step.

        Take a manual snap shot again and get snap id

        SQL> EXEC DBMS_WORKLOAD_REPOSITORY.create_snapshot;
SQL> select max(snap_id) from dba_hist_snapshot;

        *** Run This block using Sysdba ***
        Set serveroutput on
DECLARE
cur1 DBMS_SQLTUNE.SQLSET_CURSOR;
cur2 DBMS_SQLTUNE.SQLSET_CURSOR;
h1 NUMBER ;
v_schema_name VARCHAR2(30) := '&1' ;
v_tablespace_name VARCHAR2(30) := 'USERS'
v_table_name VARCHAR2(10) := '&2' ;
v_sts_name VARCHAR2(10) := '&3' ;
v_logfile VARCHAR2(30) ;
v_dumpfile VARCHAR2(100) ;
v_export_name VARCHAR2(30) ;
v_condition VARCHAR2(100) ;
v_beginsnap number;:= &4;
v_endsnap number;:= &5;
BEGIN
v_logfile := v_schema_name || '_' || v_sts_name || '_' || to_char(SYSDATE,'yyyymmdd') || '.dmp.log' ;
v_dumpfile := v_schema_name || '_' || v_sts_name || '_' || to_char(SYSDATE,'yyyymmdd') || '.dmp.log' ;
v_export_name := 'STS_' || v_sts_name || '_' || to_char(SYSDATE,'yyyymmdd') ;
v_condition := 'parsing_schema_name <> ' || '''' || 'SYS' || '''' || ' AND (sql_text like ' || '''' || 'SELECT%' || '''' || ' or sql_text like ' || '''' || 'select%' || '''' || ') ' ;
-- Create the sql set
DBMS_OUTPUT.PUT_LINE ('Creating SQL Tuning Set') ;
DBMS_SQLTUNE.CREATE_SQLSET(sqlset_name => v_sts_name, sqlset_owner=> v_schema_name);
-- open cursor of our sql to load into the tuning set
OPEN cur1 FOR
SELECT VALUE(P)
FROM table(DBMS_SQLTUNE.SELECT_CURSOR_CACHE(v_condition, NULL, NULL, NULL, NULL, 1, NULL, 'ALL')) P;
DBMS_OUTPUT.PUT_LINE ('Loading Buffer Cache Data into SQL Tuning Set') ;
DBMS_SQLTUNE.LOAD_SQLSET(sqlset_name => v_sts_name, populate_cursor => cur1, sqlset_owner=> v_schema_name);
CLOSE cur1 ;
OPEN cur2 FOR
SELECT VALUE(P)
FROM
table(DBMS_SQLTUNE.SELECT_WORKLOAD_REPOSITORY(&4,&5,v_condition,NULL, NULL,NULL,NULL,1,NULL,'ALL')) P;
DBMS_OUTPUT.PUT_LINE ('Loading AWR Data into SQL Tuning Set.') ;
DBMS_SQLTUNE.LOAD_SQLSET(sqlset_name => v_sts_name,
populate_cursor => cur2,
load_option => 'MERGE',
update_option => 'ACCUMULATE',
sqlset_owner=>v_schema_name) ;
CLOSE cur2 ;
END ;
/
**************************************************************************************

**************************************************************************************

Step 5: Repeat the above 4a or 4b after the change in the parameter

alter session set optimizer_features_enable='11.2.0.2';

and again ask App team to run the load, change the name of the above load run to "Parallel2"

**************************************************************************************

Step 6: Analysis the task name

    EXEC DBMS_SQLPA.EXECUTE_ANALYSIS_TASK(task_name => 'Parallel1', -
execution_type => 'TEST EXECUTE', -
execution_name => 'Parallel1') ;

    EXEC DBMS_SQLPA.EXECUTE_ANALYSIS_TASK(task_name => 'Parallel1', -
execution_type => 'TEST EXECUTE', -
execution_name => 'Parallel2') ;

**************************************************************************************

Step 7: Compare the performances (Applicable from Parallel 2 run only)

    begin
dbms_sqlpa.execute_analysis_task(
task_name => 'Parallel2',
execution_type => 'compare performance',
execution_name => 'analysis_results',
execution_params => dbms_advisor.arglist('Parallel1','1stRUN','Parallel2', '2ndRUN'));
end ;
/

**************************************************************************************

Step 8: Report

    spool SPA_COMPARE_REPORT.out
-- Get the whole report for the single statement case.
SELECT DBMS_SQLPA.REPORT_ANALYSIS_TASK('Parallel2') from dual;
-- Show me the summary for the sts case.
SELECT DBMS_SQLPA.REPORT_ANALYSIS_TASK('Parallel2', 'TEXT', 'TYPICAL', 'SUMMARY')
FROM DUAL;
-- Show me the findings for the statement I'm interested in.
SELECT DBMS_SQLPA.REPORT_ANALYSIS_TASK('Parallel2', 'TEXT', 'TYPICAL', 'FINDINGS', 5) from dual;
spool off

**************************************************************************************

Hope this helps.