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

Turn off or disable the adaptive cursor sharing in 11g

Adaptive cursor sharing as you all aware , This was introduced in 11gR1 to address issues related to bind variable peeking. See support note 740052.1 and documentation for details.

You may have weird behaviors of your sql’s after upgrade to 11g , this may be due to no proper testing done, or optimizer features that came with 11g like ACS etc.

To disable the Adaptive cursor sharing if you want , According to support note 11657468.8

, Set the following two parameters

_optimizer_adaptive_cursor_sharing = false,

_optimizer_extended_cursor_sharing_rel = "none"

 

alter system set “_optimizer_adaptive_cursor_sharing = false”;

alter system set “_optimizer_extended_cursor_sharing_rel” = "none";

Or you can do at session level as well.

alter session set “_optimizer_adaptive_cursor_sharing = false”;

alter sesssion set “_optimizer_extended_cursor_sharing_rel” = "none";

-Thanks

Geek DBA

Adaptive Cursor Sharing: What is Adaptive Cursor Sharing?

The following is the direct extract from the documentation on adaptive cursor sharing.

The adaptive cursor sharing feature enables a single statement that contains bind variables to use multiple execution plans. Cursor sharing is "adaptive" because the cursor adapts its behavior so that the database does not always use the same plan for each execution or bind variable value.

For appropriate queries, the database monitors data accessed over time for different bind values, ensuring the optimal choice of cursor for a specific bind value. For example, the optimizer might choose one plan for bind value 9 and a different plan for bind value 10. Cursor sharing is "adaptive" because the cursor adapts its behavior so that the same plan is not always used for each execution or bind variable value.

Adaptive cursor sharing is enabled for the database by default and cannot be disabled. Note that adaptive cursor sharing does not apply to SQL statements containing more than 14 bind variables.

Continue reading Adaptive Cursor Sharing: What is Adaptive Cursor Sharing?

ORA-19566: exceeded limit of 0 corrupt blocks for file : Block that not part of any segment

Getting this error,

RMAN-00571: ======================================================
RMAN-00569: ========= ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: =====================================================
RMAN-03009: failure of backup command on ch02 channel at 10/08/2012 18:18:35
ORA-19566: exceeded limit of 0 corrupt blocks for file /testdb/dev/oradata/test13.dbf

Get the file id of the above file using

select file_id from dba_data_files where file_name='/testdb/dev/oradata/test13.dbf';

File_id
------
16

If the backup is in tape

RMAN> RUN {
allocate channel ch01 TYPE 'SBT_TAPE';
send 'NB_ORA_CLIENT=<tapebackupserver>';
BACKUP VALIDATE CHECK LOGICAL datafile 16;
}

If the backup is in disk

RMAN> RUN {
allocate channel ch01 TYPE disk;
BACKUP VALIDATE CHECK LOGICAL datafile 16;
}

Now Check the view for block corruption

SQL> SELECT * FROM v$database_block_corruption;

     FILE#     BLOCK#     BLOCKS CORRUPTION_CHANGE# CORRUPTIO
---------- ---------- ---------- ------------------ ---------
       16    1719526          1                  0 FRACTURED

You can also use the script located in this post which may give you object name of this corrupted block as well.

Link:-

SELECT owner, segment_name, segment_type, partition_name,
FROM dba_extents
   WHERE file_id=16
   AND 1719526 BETWEEN block_id AND block_id+blocks-1;

no rows selected

If you get no rows, that means you have a corrupted block reported that is not part of any segment, RMAN reads blocks on the disk level, so it is not aware if they belong to an object. Thus if an object with corrupted blocks is dropped, those blocks remain FRACTURED until reused by a new object or allocated to an existing segment. At that time, Oracle will reformat the block (renew it) and thus remove the fracture.

Solution:- Use maxcorrupt to the number that is reported in above query, i.e above i have been shown only 1 block

RMAN> SET MAXCORRUPT FOR DATAFILE 16 to 1;
BACKUP DATABASE;

-Thanks

Geek DBA

More nested loops in 11g : A change in nested loops around in 11g

Original and New Implementation for Nested Loop Joins

Oracle Database 11g Release 1 (11.1) introduces a new implementation for nested loop joins. As a result, execution plans that include nested loops might appear different than they did in previous releases of Oracle Database. Both the new implementation and the original implementation for nested loop joins are possible in Oracle Database 11g Release 1 (11.1). So, when analyzing execution plans, it is important to understand that the number of NESTED LOOPS join row sources might be different.
Original Implementation for Nested Loop Joins

Consider the following query:

SELECT e.first_name, e.last_name, e.salary, d.department_name
    FROM hr.employees e, hr.departments d
    WHERE d.department_name IN ('Marketing', 'Sales')
      AND e.department_id = d.department_id;

before Oracle Database 11g Release 1 (11.1), the execution plan for this query might appear similar to the following execution plan: Continue reading More nested loops in 11g : A change in nested loops around in 11g

Basics: Oracle Corruptions Series #3: How to find physical corruptions and limitations with each approach.

Series: Part 1, Part 2, Part3

Typical Oracle physical corruptions may pose are,

(a) ORA-01578 - This error explains physical structural damage with a particular block.

(b) ORA-08103 - This error is a logical corruption error for a particular data block.

(c) ORA-00600 [2662] - This error is related to block corruption , and occurs due to a higher SCN than of database SCN.

1) How to check Oracle Physical block corruption?

Continue reading Basics: Oracle Corruptions Series #3: How to find physical corruptions and limitations with each approach.

Basics: Oracle Corruptions Series #2: Very good note on different types of Oracle corruption

Series: Part 1, Part 2, Part3

Some good metalink notes for my reference and for your record.

Master Note for Handling Oracle Database Corruption Issues [ID 1088018.1]

Identify the corruption extension using RMAN/DBV/ANALYZE etc [ID 836658.1]

Handling Oracle Block Corruptions in Oracle7/8/8i/9i/10g/11g [ID 28814.1]

How to identify all the Corrupted Objects in the Database with RMAN [ID 472231.1]

-Thanks

Geek DBA

Basics: Oracle Corruptions series #1: Physical & Logical Corruptions in Oracle

Series: Part 1, Part 2, Part3

Oracle will have two types of corruptions , Physical & Logical corruptions.

Physical Block Corruptions

This kind of block corruptions are normally reported by Oracle with error ORA-1578 and the detailed corruption description is printed in the alert log.
Corruption Examples are:

  • Bad header - the beginning of the block (cache header) is corrupt with invalid values
  • The block is Fractured/Incomplete - header and footer of the block do not match
  • The block checksum is invalid
  • The block is misplaced
  • Zeroed out blocks / ORA-8103

Continue reading Basics: Oracle Corruptions series #1: Physical & Logical Corruptions in Oracle

How to find whether your tablespace is in exadata storage? How to use hybrid columnar compression in non exadata.

Ofcourse you will have a manual that states about your environment.

But how to get it from the database.

In otherwords if you have given a database to check your tablespaces that is running in exadata storage and you want to uae hybrid columnar compression (possible only with exadata)

Humor; dont say you run create tablespace. ...... Compress for high. and if you get error then its not exadata storage.

before going forward, Look at this ouput of dba_tablespace , in 11g

SQL> select tablespace_name,predicate_evaluation from dba_tablespaces;

TABLESPACE_NAME                PREDICA
------------------------------ -------
SYSTEM                         HOST
SYSAUX                         HOST
TEMP                           HOST
USERS                          HOST

10 rows selected.

SQL>

A new column predicate_evaluation is added, lets see 10.2.0.4 dba_tablespaces description

10.2.0.4 Output
==============

SQL> desc dba_tablespaces
Name                                      Null?    Type
----------------------------------------- -------- ----------------------------
TABLESPACE_NAME                           NOT NULL VARCHAR2(30)
BLOCK_SIZE                                NOT NULL NUMBER
INITIAL_EXTENT                                     NUMBER
NEXT_EXTENT                                        NUMBER
MIN_EXTENTS                               NOT NULL NUMBER
MAX_EXTENTS                                        NUMBER
PCT_INCREASE                                       NUMBER
MIN_EXTLEN                                         NUMBER
STATUS                                             VARCHAR2(9)
CONTENTS                                           VARCHAR2(9)
LOGGING                                            VARCHAR2(9)
FORCE_LOGGING                                      VARCHAR2(3)
EXTENT_MANAGEMENT                                  VARCHAR2(10)
ALLOCATION_TYPE                                    VARCHAR2(9)
PLUGGED_IN                                         VARCHAR2(3)
SEGMENT_SPACE_MANAGEMENT                           VARCHAR2(6)
DEF_TAB_COMPRESSION                                VARCHAR2(8)
RETENTION                                          VARCHAR2(11)
BIGFILE                                            VARCHAR2(3)

SQL>

Its not there, in 11gr2 this column along with other new two columns there.

11.2.0.2 Output (infact from 11.1.0.0 onwards)
===============

SQL> desc dba_tablespaces
Name                                      Null?    Type
----------------------------------------- -------- ----------------------------
TABLESPACE_NAME                           NOT NULL VARCHAR2(30)
BLOCK_SIZE                                NOT NULL NUMBER
INITIAL_EXTENT                                     NUMBER
NEXT_EXTENT                                        NUMBER
MIN_EXTENTS                               NOT NULL NUMBER
MAX_EXTENTS                                        NUMBER
MAX_SIZE                                           NUMBER
PCT_INCREASE                                       NUMBER
MIN_EXTLEN                                         NUMBER
STATUS                                             VARCHAR2(9)
CONTENTS                                           VARCHAR2(9)
LOGGING                                            VARCHAR2(9)
FORCE_LOGGING                                      VARCHAR2(3)
EXTENT_MANAGEMENT                                  VARCHAR2(10)
ALLOCATION_TYPE                                    VARCHAR2(9)
PLUGGED_IN                                         VARCHAR2(3)
SEGMENT_SPACE_MANAGEMENT                           VARCHAR2(6)
DEF_TAB_COMPRESSION                                VARCHAR2(8)
RETENTION                                          VARCHAR2(11)
BIGFILE                                            VARCHAR2(3)
PREDICATE_EVALUATION                               VARCHAR2(7)
ENCRYPTED                                          VARCHAR2(3)
COMPRESS_FOR                                       VARCHAR2(12)

What does those three extra columns

PREDICATE_EVALUATION : Indicates whether predicates are evaluated by host (HOST) or by storage (STORAGE)

ENCRYPTED   : Indicates whether the tablespace is encrypted (YES) or not (NO)

COMPRESS_FOR : Default compression for what kind of operations: •DIRECT LOAD ONLY•FOR ALL OPERATIONS•NULL

Now back to Post, how to find the tablespace is in exadata storage? WELL the answer is to know about what is predicate_evaluation above?

This columns says whether the disk attribute is set for exadata storage or normal storage,

If its exadata storage ( show storage) some options like "compress high" etc will be run on those tablespaces.

If its normal storage (show host) , compress high etc will not be possible.

As my above output shows,  HOST my tablespaces are in normal database with normal storage. not in the exadata.

SQL> select tablespace_name,predicate_evaluation from dba_tablespaces;

TABLESPACE_NAME                PREDICA
—————————— ——-
SYSTEM                         HOST
SYSAUX                         HOST
TEMP                           HOST
USERS                          HOST

Still if you want to play around, you can change the predicate_evaluation for tablespace (when using asm diskgroup) by changing the attribute using kfed (upcoming post)

-Thanks
Geek DBA

ORA-01031 insufficient privileges while creating database link

My friend has an issue yesterday which took sometime to figure out in important time during a release. Hooe this may help you too.

ORA-01031: insufficient privileges , while creating DB Link

SQL> select * from dba_sys_privs;

USERNAME PRIVILEGE ADM
------------------------------ ---------------------------------------- ---
TEST321 ALTER ANY PROCEDURE NO
TEST321 CREATE DATABASE LINK NO
TEST321 CREATE PUBLIC DATABASE LINK NO
TEST321 CREATE SESSION NO
TEST321 DELETE ANY TABLE NO
TEST321 EXECUTE ANY PROCEDURE NO
TEST321 INSERT ANY TABLE NO
TEST321 SELECT ANY TABLE NO
TEST321 UNLIMITED TABLESPACE NO
TEST321 UPDATE ANY TABLE NO

Even if I grant DBA priv I cant seem to create:

SQL> conn
Enter user-name: / as sysdba
Connected.
SQL> grant dba to TEST321;

Grant succeeded.

SQL> conn TEST321/bet123
Connected.

SQL> create database link test.world connect to PROD321 identified by ***** using 'test.world';
create database link TEST.world connect to PROD321 identified by *****
*
ERROR at line 1:
ORA-01031: insufficient privileges

What could be the reason?  uh! After verifying we found that ,

1) There is a logon trigger

SQL> select trigger_name,trigger_type,triggering_event  from dba_triggers where trigger_name='T_LOGON';

TRIGGER_NAME  TRIGGER_TYPE     TRIGGERING_EVENT
------------- ---------------- ----------------
T_LOGON       AFTER EVENT      LOGON

SQL>

2) Logon trigger written as, sets any user that logon this database will automatically set to another user TEST

Here is the piece of Trigger code

select text from dba_source where name='T_LOGON';

TRIGGER T_Logon

AFTER LOGON ON DATABASE
--
DECLARE
--
CURSOR c1 IS
.....

EXECUTE IMMEDIATE 'ALTER SESSION SET CURRENT_SCHEMA = TEST';

.....

This means, after immediately TEST321 logs on to the database , the session will be set as TEST

So , Well now the reason, the user TEST321 cannot create objects in TEST and thats why the reason ORA-01031, but question why still despite of granting DBA Role is failing,
again TEST does not have DBA Privs 🙂 we are granting to TEST321.

Now to resolve this, we have to again to set current_schema of our own

SQL> conn TEST321/bet123
Connected.

SQL> alter session set current_schema=TEST321;
Session altered.

SQL> create database link test.world connect to PROD321 identified by ***** using 'test.world';
Database link created.

Hope this helps.

Basics: Different Types of Checkpoints in Oracle

What is a Checkpoint?

  • A synchronization event at a specific point in time
  • Causes some or all dirty block images to be written to the database thereby guaranteeing that blocks dirtied prior to that point in time get written
  • Brings administration up to date
  • Several types of checkpoint exist

Types of Checkpoints?

  • Full Checkpoint
  • Thread Checkpoint
  • File Checkpoint
  • Object “Checkpoint”
  • Parallel Query Checkpoint
  • Incremental Checkpoint
  • Log Switch Checkpoint

Continue reading Basics: Different Types of Checkpoints in Oracle