2013-12-20

DUMP to HEX


DUMP function gives decimal presentation of a column contents bits.

select ch,dump(ch) dm 
from (
select 'DUMP to DEC' ch 
from dual
)
;


CH DM
DUMP to DEC Typ=96 Len=11: 68,85,77,80,32,116,111,32,68,69,67

Sometimes hexadecimal presentation would be nice

select ch
     , listagg(to_char((column_value).getnumberval(),'XX'))
        within group (order by rownum) hex 
 from (
  select ch,dump(ch) dm 
   from (
    select 'DUMP to HEX' ch 
      from dual
    )
  ) n
  ,xmltable(substr(n.dm,instr(n.dm,':')+2))
;

CH HEX
DUMP to HEX  44 55 4D 50 20 74 6F 20 48 45 58

Or maybe it is easier just to use the documented second parameter of dump function.

select ch,dump(ch,1016) dm 
 from (
  select 'DUMP to HEX' ch 
  from dual
 )
;


DUMP to HEX    Typ=96 Len=11 CharacterSet=AL32UTF8: 44,55,4d,50,20,74,6f,20,48,45,58

2013-12-02

Is My Index Used

I am in Manchester. The UKOUG tech13 seminar super Sunday information overload gone. Three days still left. I got finally to meet Kyle Hailey. The man who visualized the ash. Even he and Doug Burns could not find the SQL query that has created the lock in a blocking session. Another a bit similar question that is often asked. Is an index used. You could set up monitoring on an index.

ALTER INDEX index_name_here MONITORING USAGE;

And after a while you can browse USED column of the V$OBJECT_USAGE view.
It tels is your undex been used. But it does not tell if the index is used wisely. ASH to the rescue. Possibly increase the time ash is stored. And here is a query that shows the clauses that have been using the index.

select sql_id,TO_CHAR(substr(sql_text,1,4000)) txt
  from dba_hist_sqltext where sql_id in ( 
  select sql_id 
    from dba_hist_sql_plan 
   where object_name = :index_name)
order by txt
;

If no index usage is noticed. The index is a possible candidate for dropping away. The case in V$OBJECT_USAGE.

But it might be so that the index is used in a non wisely manner. From there on you can interpret the plans. It might be that the full table scan would perform better.

And going to 12c there becomes the adaptivity of a cursor execution that will end up in the plan even it executes better in other execution paths. This was covered yesterday quite nicely by Nicolas Jardot. So for 12c the is the index used query here should be attached to dba_hist_active_sess_history. Future work to be done.

Before dropping consider making the index invisible for awhile.


About Me

My photo
I am Timo Raitalaakso. I have been working since 2001 at Solita Oy as a Senior Database Specialist. I have received Oracle ACE nomination. My main focus is on projects involving Oracle database. In this Rafu on db blog I write some interesting issues that evolves from my interaction with databases. Mainly Oracle.