วันอาทิตย์ที่ 16 กันยายน พ.ศ. 2555

ORA-01410: invalid rowid

Oracle error ORA-01410: invalid rowid. It’s a problem I’ve responded to a few times in newsgroups and presentations, but I realised recently that despite mentioning it casually for several years I’ve never written a specific note about it – so here it is.


Although most indexes in Oracle can safely be left to keep themselves tidy and efficient some DBAs (possibly many DBAs) have been persuaded that rebuilding indexes regularly is a good thing. Other DBAs are a little more cautious and write programs that attempt to make a sensible decision about which indexes really do need to be rebuilt – and then report suspect indexes rather than rebuilding them.
Even if you fall into the latter group and do manage to identify the few indexes that can benefit from being rebuilt,be careful about letting the rebuilds take place automatically – the timing can be critical.
Consider this: if you rebuild an index (whether or not you use the online option) Oracle will copy the index contents from one location to another and, when the copy is complete, free up the space that held the original index contents.
What’s going to happen to a long running query that started running before you did your rebuild ? Surprisingly the query will carry on running using the “old” index. Oracle introduced a form of ‘cross-DDL read consistency’ many years ago to make partition maintenance operations possible, and that’s the feature that allows your query to carry on running.
But what’s going to happen if some other process now demands the space and puts something into it – for example by creating or extending a table or index (เช่นสร้าง table ใน tablespace เดียวกัน). The next time your long-running query hits the “old” index it may find itself looking at a block that contains the wrong type of data for the wrong object id. And so you get Oracle error ORA-01410: invalid rowid.
The effect is easy to demonstrate if you start with a completely empty tablespace (preferably locally managed with uniform extents, though this isn’t an absolute necessity):

###Prepare Environment
create table t1 nologging as
select
    rownum  id,
    rpad(rownum,10) v1,
    rpad('x',100)   v2
from
    all_objects
where
    rownum <= 10000;

alter table t1 add constraint t1_pk primary key(id);
execute dbms_stats.gather_table_stats(user,'t1');

###Run Some SQL Report on Session1
declare
    m_v1 varchar2(10);
begin
    for r in (select /*+ index(t1) */  v1 from t1 where id > 0)
    loop
        m_v1 := r.v1;
        dbms_lock.sleep(0.01);
    end loop;
end;
/

###Open Session2 And Doing Following Command
alter index t1_pk rebuild online nologging;
create table t2 nologging as select * from t1;

The new table t2 should fill the hole left by rebuilding the index t1_pk, and your first session should crash moments later.
The behaviour is much less predictable on production systems, of course. In the real world a random process may simply crash at some random time in the overnight batch once every few weeks for no apparent reason


Credit : Jonathan Lewis


Hope this help you to more understand :D
Chatchai Komrangded











วันศุกร์ที่ 19 พฤศจิกายน พ.ศ. 2553

Smart File Creation with Oracle Exadata

Hi ,

From last week  , I completed Oracle Exadata POC with my customer and I'm very surprised with Exadata performance because first time I hearing about Exadata performance , I just say "I don't trust it" , "I can tuning sql , db performance faster than it."  ok , don't talk to much.
This section I would like to proof concept of Smart file create on Oracle Exadata Feature.
See the follow Test case during  S.. XXX  Machine V.S. Exadata Machine.
Note
-S... XXX disk I/O per sec around 384 MB /sec
-Number of disks is equal in +DATA diskgroup.

S.. XXX Machine
CHATCHAI_K > create tablespace TEST datafile '+DATA' size 30G , '+DATA' size 30G , '+DATA' size 30G , '+DATA' size 30G;

Tablespace created.

Elapsed: 00:06:15.23

----------------------------------------------------------------------------

Exadata Machine
EXADATA_HALF_RACK > create tablespace TEST datafile '+DATA' size 30G , '+DATA' size 30G , '+DATA' size 30G , '+DATA' size 30G;

Tablespace created.

Elapsed: 00:01:11.70


"Oh it faster" why it faster ? , I looking for v$sysstat relate optimizing file creation that oracle don't  format any new data block in memory and sending through interconnect but I simply say hey ! storage server I would like to create 4 datafile each size 30G let do it for me  , everyting offloading to the cell storage no format block level and more task on database server , This feature is call "Smart File Creation"

Cheer ,

วันอาทิตย์ที่ 31 ตุลาคม พ.ศ. 2553

How to disable ADDM after AWR snapshot

Do not apply step in this topic to production environment becuase changing internal parameter leading oracle software to unsupport by global support.

I believe many of dba love ADDM  , it is good friend but some senior or dba who had a lot of tuning expriece may don't trust or like it  , someone talk Hey ! I would like to use my knowledge for anlyze the system , how is going on  , how to leave it from his/her life because it so alluring to use.
the follow is step to disable addm :
 
  $ sqlplus /nolog
  CHATCHAI_K > conn / as sysdba
  CHATCHAI_K > alter system set "_addm_auto_enable"  = false scope=both sid='*';
 
Cheer !!
However ADDM is a good utility to helping you to faster tracking the overall system performance analysis and any sql statement may have a problem compare with the period time.

Oracle NULL=NULL or NULL is NULL ?

I'm believe many of people confuse  null = null is equal null is null or not ? , which method should be, how about performance or something elase ,
however This topic we'll prove oracle treat the null value together

Considerate the easier example :
   CHATCHAI_K> select sysdate from dual where null=null
   no row selected
   CHATCHAI_K> select sysdate from dual null is null
   sysdate
   -
   31-OCT-10

from example  it prove  oracle NULL is not equal to NULL, but in some database vendor such as Sybase null is equal to null  , therefore when you migrate database from one to another , your application may retrieve a wrong result that is not database processing wrong but it is just work difference that you need to understand !

Cheer !

วันเสาร์ที่ 30 ตุลาคม พ.ศ. 2553

How do I change the name of the oracle database

Hi all this is first post in my web blog   , I'm database consult (oracle & mysql) , I would like to share some tip , technique and new technology of oracle and mysql to helping people be successful to  , from first topic we'll going  to how to change oracle database name as
here is step by step :
 
1. Backup the database first ( via alter tablespace begin backup , rman or some backup tools) (the process of backup that beyond scope of my topic.)

2. Logon to database and shutdown :
      $ sqlplus /nolog
      SQL> conn / as sysdba
      SQL> select count(1) from v$transaction
      or in RAC used gv$transaction instead.
      SQL> shutdown immediate;
      SQL> startup mount;
 3.  Call DBNEWID utility with sysdba
       $ nide target=sys/password dbname=new_name setname=yes
 4.   Shutdown database
 5.   Change New name :
       $ sqlplus /nolog
       SQL> conn / as sysdba
       SQL> startup nomount;
       SQL> alter system set db_name=new_name scope=spfile;
       SQL> shutdown immediate;
 6.   Create new password file
        $ orapwd file=$ORACLE_HOME/dbs/pwdnew_name.ora password=password entries=5
 7.    Reset ORACLE_SID environment in .profile (aix,solaris) or .bash_profile(linux)
        Change to
            ORACLE_SID=new_name;export ORACLE_SID
        or in the shell terminal try
            export ORACLE_SID=new_name
 8.    Alter listener.ora and tnsname.ora settings to match the new database and restart listener by:
        $ lsnrctl reload
  9.   Startup (no resetlog require for change database name only)
        $ sqlplus /nolog
        SQL> conn / as sysdba
        SQL> startup