Oracle Logbook

March 28, 2011

What objects should go to recycle

Filed under: Uncategorized — Helio Dias @ 8:03 pm

Basically the objects with very low TCH
Col object_name format a30
Col object_type format a20
SELECT o.owner, object_name, object_type, COUNT(1) buffers
FROM SYS.x$bh, dba_objects o
WHERE (tch = 1 OR (tch = 0 AND lru_flag < 8))
AND obj = o. object_id
AND o.owner not in ('SYSTEM','SYS')
GROUP BY o.owner, object_name, object_type
ORDER BY buffers;


March 25, 2011

Bitmap or Btree

Filed under: Uncategorized — Helio Dias @ 3:35 pm

Today I faced with this question at:

========================================= The Question ================

I have a table having 5 million records.

If I want to build an index on one column,which index is better(bitmap or btree normal)?

The column had approx 6% different values for the total records in the table.


My answer was:

With 5%, I’d go through btree,
bitmap have many detail that you should be aware.

March 22, 2011

Exists and IN which is better?

Filed under: Uncategorized — Helio Dias @ 5:02 pm

Today I saw this question at:

My answer was:

There are two major difference between IN and EXISTS

The first difference is about what table will be the driving table

The second and most important difference is that EXISTS is a bit more flexible, because even when you overuse EXISTS, most of the time , Oracle is smart enough to change it to a IN, So if you don´t understand very well the concept about driving table and execution path, use EXISTS.

March 18, 2011

An Oracle user and scheme are the same?

Filed under: Uncategorized — Helio Dias @ 4:38 pm

Almost , but not exactly.

An Oracle user is the USERNAME, the SCHEMA is the set of objects associated with one OWNER

So when a USER become a SCHEMA? when he get the privileges to create objects;

Another thought, after login you are the user that you logon, but if you do an Alter session set current_schema=another_schema; 

Then you will be one user, but another schema.

Of course , to makes things easier to understand , you can think that they are the same.

One important thing, Inside Oracle dictionary tables just exists the USER

March 16, 2011


Filed under: Uncategorized — Helio Dias @ 8:30 pm

If you what to run everyday at 1AM





Who to use EXISTS in an update

Filed under: Uncategorized — Helio Dias @ 6:16 pm

UPDATE table_1 t1

SET A.column_1 = (SELECT t2.column_2-t1.column_1 FROM table_2 t2


WHERE EXISTS (SELECT  null FROM table_2 t2


March 15, 2011

Searching for FULL table scan

Filed under: Uncategorized — Helio Dias @ 6:39 pm

Today I saw this question at OTN:

“Can someone provide me asql query which will show me the actual query which is going for FTS including how many time that FTS query executes so far.”

=========== My answer  =========

If your goal is to search possible queries with problems, you should try this:

select * from (
select sql_id,buffer_gets,executions,rows_processed from v$sqlarea order by 2 desc)
where rownu<30;

Then you should evaluate if make sense 10 rows query, executed just 5 times, consume 100,000 buffer_gets.
why some queries are being executed 1 billion times.

the botton line is , search weird things, and improve it.

You maybe even find out a huge consuming buffer_gets query that need a index,
Just keep in mind, FTS is not synonym of problem.
And even when it´s actually a problem, searching one by one , it´s not for sure the best aproach.

Avoiding logon trigger

Filed under: Uncategorized — Helio Dias @ 3:34 pm

Sometimes people can´t access the database any longer due to a system event logon trigger.

If this happen the solution is change the hidden parameter _system_trig_enabled to false.

March 11, 2011

Difference in gathering statistics

Filed under: Uncategorized — Helio Dias @ 8:29 pm

The major difference between DBMS_STATS.GATHER_DATABASE_STATS_JOB_PROC and DBMS_STATS.GATHER_DATABASE_STATS is that GATHER_DATABASE_STATS_JOB_PROC is smart enough to start the analyze with most in need objects.

Wait event : Read by other session

Filed under: Uncategorized — Helio Dias @ 4:02 pm

In case the contention is on indexes, I would recreate the primary key using reverse index.
Before do this , you should be aware the drawback regarding range scan.

This was my answer at!reply.jspa?messageID=9432150

Next Page »
March 2011
  • Recent Posts

  • Recent Comments

    wordman512 on Grouping with Rollup
    heliodias on AWR it´s not free and requires…
    Venkata on AWR it´s not free and requires…
    jsixface on Best way to delete millions ro…
    heliodias on What objects should go to…
  • _

  • Pages

  • Archives

  • Blog Stats

    • 129,788 hits
  • Blog at