Subscribe to Posts by Email

Subscriber Count

    703

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

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.

Switching on/off bug fixes / patches

From 10g onwards there is a hidden parameter _fix_control that can be used to turn off/on a particular bug fix. (Be sure, this is hidden parameter and as usual note changing hidden parameters must be done after consulting Oracle)

For example, a patch 5483301 has been recently applied to the database using opatch, and after that you  have seeing some issues, you want to determine the root cause, but you cannot rollback the patch to test, in such scenarious this hidden parameter can come in handy.

Given the same scenario, First check the patch registered and enabled. (replace your patch number)

SQL> select bugno, value, description, optimizer_feature_enable from v$system_fix_control where bugno=5483301;

BUGNO           VALUE      DESCRIPTION                          OPTIMIZER_FEATURE_ENABLE

5483301          1             Use min repeat count                    10.2.0.4

                                       in freq histogram to compute the density

 

As my patch is listed here, I can disable and determine that the issue happening in the database is because of this patch or not. to do same.

alter system set "_fix_control"='5483301:off' scope=both;
or for the session
alter session set "_fix_control"='5483301:off';

SQL> select bugno, value, description, optimizer_feature_enable from v$system_fix_control where bugno=5483301;

BUGNO VALUE DESCRIPTION OPTIMIZER_FEATURE_ENABLE

5483301 0 Use min repeat count 10.2.0.4

in freq histogram to compute the density

Now try to reproduce the issue you have. Once you determine the issue is because of this patch , you can let the bug fix off in the database or let it enable back.

alter system set "_fix_control"='5483301:on' scope=both;
or for the session
alter session set "_fix_control"='5483301:on';

Note:- provided only for educational purposes only, not to try in production systems unless you are sure what you are doing.

-Thanks

Geek DBA

Quiz Post #5: Restore statistics and history facts

Q1. Can we get old statistics restored for an object for example for a index or a table ?

Yes we can get the old statistics restored from Oracle version 10g onwards.However, if you use ANALYZE for statistics collection in 10g, automatic saving is not possible.

Q2. If so, where do the statistics history stored in and what is the retention?

DBA_OPTSTAT_OPERATIONS contain history of statistics operations performed.The retention period default value is 31 days.You would be able to restore the optimizer statistics to any time in last 31 days.

Select * from dba_optstat_operations where target like ‘%’;

DBA_TAB_STATS_HISTORY view contain a history of table statistics modifications.

Q3. Is it possible to restore a index statistics and where can I find the information?

RESTORE_TABLE_STATS procedure restores the statistics of a table along with this it also restores the index statistics associated with the table.However, the index statistics is not restored in case index is rebuild just before issuing restore_table_stats in 10g.This bug 5519322 is fixed in 11g release 2.Instead we can use DBMS_STATS.EXPORT_*_STATS and DBMS_STATS.IMPORT_*_STATS procedures, but before this we need to create a table to hold this statistics "DBMS_STATS.CREATE_STAT_TABLE".

-Thanks