Monday, December 21, 2009

BULK UPDATE using FORALL in Oracle PLSQL - Awesome experience..

In one of the projects I work, there arose a need to conditionally update a few column values of a table. How many rows did we need to update ? Roughly 5 million rows out of 252 million total rows.

Experimented many approaches to get this done. Some of them ....
1. Use a single UPDATE statement (Worst thing to ever do for huge data updates)
2. Update in lots of 50K - using plain update statement (Kind of OK, though it handled shorter commits, I wasnt happy with performance)
3. Fantastic result : When I used PLSQL(bulk update using FORALL), I realized I had been under utilizing PLSQL for my day to day jobs. No doubt... Oracle PLSQL rocks.

Tuesday, June 9, 2009

CouchDB - Are we getting oriented to newer DBs ?

It was inspiring to read about CouchDB - Document based DB. Is it going to mark the end of the RDBMS era ? I have my own questions of how faster a fetch operation could be made on a document based DB.


Or will this confined to specific applications ? Lets wait for CouchDB's user experience feedback.

Thursday, May 14, 2009

When is the next post ?

Work has been keeping me very busy ... Recently I was going thru Oracle performance tuning guide. Also found some interesting problems on the job. I am sketching the content. will post soon.

Thursday, April 23, 2009

New work laptop

I just started loving the new laptop Dell Latitude E6400. Its looks are awesome !
Will wait for a Mac Book option too. When will the day come ?

Friday, April 10, 2009

Recompiling to validate the INVALID Objects : Oracle

On a DB schema, there are many database objects like tables, views, procedures, packages etc.

Here is a case study...
- You want to alter a table for some reason. As a result of running ALTER statement over the table, all dependend objects like Views, Packages gets invalidated irrespective of the fact that change affects/not affects the dependend objects.
- Eg: Assume a table ..

SQL> create table test_foo
( colA varchar2(2)
, colB varchar2(2)
, colC varchar2(2)
);

SQL> create view v_test_foo
as select colA, colB, colC from test_foo;


SQL> select object_name, object_type, status
from user_objects
where object_name in ('TEST_FOO', 'V_TEST_FOO');

----------------------------------------
object_name object_type Status
-----------------------------------------
V_TEST_FOO VIEW VALID
TEST_FOO TABLE VALID


SQL> alter table test_foo add colNew varchar(2);


SQL> select object_name, object_type, status
from user_objects
where object_name in ('TEST_FOO', 'V_TEST_FOO');

----------------------------------------
object_name object_type Status
-----------------------------------------
V_TEST_FOO VIEW INVALID
TEST_FOO TABLE VALID


How do you recompile these ?

I use...
SQL> exec dbms_utility.compile_schema('USERNAME');
-- Substitute an appropriate USERNAME above.

So, how does it behave in Oracle 9i and Oracle 10g ?

The behavior is different in both versions of the Oracle.
Oracle 10g: As you expect, all relevant invalid objects are recompiled and becomes Valid.

Oracle 9i: You should be cautitious.. as VIEWs are not validated.
You have to explicitly compile VIEWs as follows.
ALTER VIEW v_test_foo COMPILE;

Script to Find User Information and More ; Oracle

As a DBA, You might see a lots of users in the DB server.

There are times when you need to find out info about the roles/system pivileges assigned to an user. Following link contain some useful queries to dig information out of the data dictionary tables.

http://www.oracle.com/technology/oramag/code/tips2006/010906.html

Tuesday, March 31, 2009

Creating PLAN table in Oracle (9i)

If you need to set AUTOTRACE feature ON, you need PLAN tables created for sure. So, how do you create plan tables.

Which script ?
The script for creating Plan table is in $ORACLE_HOME\rdbms\admin\utlxplan.sql.

Where to create ?
Create the PLAN_TABLE by using utlxplan.sql in the schema where you need to enable trace and run the query.

What else is required ?
Also, create the ROLE named PLUSTRACE using a script in sqlplus\admin directory.

Grant this role to the user for whom you have created PLAN_TABLE.

Thats it ! login, run
SQL> set autotrace trace
You should be seeing the query plans.

Saturday, March 21, 2009

Evolutionary Database Design - Pramod Sadalage's presentation during Q-Con


http://www.infoq.com/presentations/refactoring-databases


Splendid coverage of Evolutionary Database design with demonstration by Pramod Sadalage, the Agile DB practices guru.

Oracle: Interesting study about count(*) function in Oracle DB

What is the fastest way to count records in a table ?

Or how fast can you find if a table is empty or not ?

I came across this in Tom Kyte's blog.
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1156159920245

Happy reading :-)

Wednesday, March 18, 2009

Blog Name Change

I decided to diversify my experience across Databases like MySql, SQL Server in the market.
Henceforth, I will share any thing that was a challenge in my day-to-day work and how we as a team, solved those issues. I'll also publish solution for the challenges we saw.

Why I suffix tiger always in my blog name ? Simple reason.. It is my national animal and signifies Valour and Pride ... here it signifies magnificient wealth of information.

Tuesday, March 17, 2009

Troubleshooting vncserver start issues

My purpose was to install Oracle DB server on a Linux server, for which I required to start a VNC session.

I ended up facing the following errors...

error opening security policy file /usr/X11R6/lib/X11/xserver/SecurityPolicy
Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!
X connection to :2.0 broken (explicit kill or server shutdown).
xterm: fatal IO error 32 (Broken pipe) or KillClient on X server ":2.0"

So, began to troubleshoot and fix errors one by one...

How to fix them ?

First, let us fix "error opening security policy file /usr/X11R6/lib/X11/xserver/SecurityPolicy".

In my machine, the actual SecurityPolicy file was available in /etc/X11/xserver/SecurityPolicy.
So, created a symbolic link at /usr/X11R6/lib/X11/xserver/ for SecurityPolicy file.

Will post again on how to fix the next issue.

Continuation...
Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!

How did I get rid of this error ?
A colleague of mine disabled the firewall on the Linux box I was using. Voila, VNC works !

Monday, February 23, 2009

Revealing the history of Oracle's SCOTT/TIGER

Who is behind the user name SCOTT ?
It was Bruce Scott, employee number #4 at the then Software Development Laboratories that eventually became Oracle. He co-authored and co-architected few versions of Oracle software.

Why SCOTT 's password is tiger ?
"tiger" is the name of SCOTT's pet cat.

Since then, scott/tiger combination continues ...

Sunday, February 8, 2009

Debut Post @ OracleTiger

Oracle Database has scaled and matured over time. The newbies to the tech field get the relevant information, not necessarily in the simplest approach. This is an move to present my Oracle Database experiences, in the Simplest possible way I could.

Thanks for the motivation by lots of friends and the student community who have been asking me about it.