| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Monday, December 14, 2009
CTAS - With few additional columns apart from the query
Friday, September 11, 2009
Changing the Database Name in 10g
Wednesday, July 8, 2009
olsnodes hangs!!!
Thursday, July 2, 2009
Long running Update SQL
Thursday, May 21, 2009
Changing the SQL Prompt to reflect the user and db connected to:
Wednesday, May 13, 2009
PZnn Processes!!!
Never heard of them before and ever cared to see what those are untill I recently found that the little tool that I wrote to kill all the sessions in the database was failing in RAC databases (you can find that in my earlier posts).
This little tool was suppose to go and kill all the sessions that are connected in the database prior to doing any upgrades and they started failing.
When I looked at there are these processes PZ99 and PZ98 sitting in gv$session and thier serial# keeps changing everytime you run a query against gv$session view and thus my little killing a session in RAC fails as the serial# is changed!!!
Anyways, what are these PZnn processes?
These are PQ slaves used for global views that are RAC Parallel Server Slave processes, but they are not normal parallel slave processes, PZnn processes (starting at 99) are used to query GV$ views which is done using Parallel Execution on all instances, if more than one PZ process is needed, then PZ98, PZ97,... (in that order) are created automatically.
Tuesday, May 12, 2009
RAC - Commonly used Terms and Utilities
Monday, March 2, 2009
How to set autotrace in SQL*Plus...
Set autotrace on | Shows the optimizer execution plan as well as statistics of the statement |
Set autotrace on explain | Shows only the optimizer execution plan |
Set autotrace on statistics | Shows only the statistics |
Set autotrace traceonly | Like SET AUTOTRACE ON, but doesn’t print a query result. |
Set autotrace off | Disables all autotrace |
Tuesday, February 10, 2009
Is that database affected with "Bind Peeking"!!!
The procedure that was written couple of years ago was running fine and smooth until we upgraded to 10g (Rel#1).
Even, in 10g it was fine for the first few weeks and then slowly started seeing lot of slowness in the system.
The stats found out this particular sql as the main culprit.
Amazingly 3GB TEMP tablespace in 8i is not enough in 10G. The TEMP tablespace grows even upto 24G (well thank god thats the max limit they set) and then fails.
Whats going on...
Din't think about this so called feature "bind peeking" from 9i but started looking into the culprit sql.
The SQL is not that complex. It has group by and one sub query. Thats all. And yeah, this SQL is the cursor though. Since its a cursor, there is a variable assignment for a where clause to filter out the records and that variable is of "date" type and the column compares this variable also is of "date" type in the table. So, everything is good there and I don't have to go for converting my variable to to_date etc.,
Well, so, why is that this particular SQL taking too much of TEMP tablespace!!!
Ran the query alone by passing the actual value instead of the variable in where clause to see how many records I get. Interestingly I get only couple of hundred rows.
That made me to think of the variable being binded in the cursor at the runtime.
So, this time my test was little different. Made a pl/sql block with the cursor and passed the variable value at run time (basically pulled out the portion of the code from the procedure) and the query hangs while being busy in increasing the temp space.
Removed the variable in the where clause and changed to get the value directly from the table instead of assigning that at the run time. Boom... query comes back in seconds...
So, my guess was right. Its the bind variable which was causing the issue and some how oracle keep increasing the temp tablespace.
Solution:
Basically the main issue here was to do with the so called feature "bind peeking". In this example while oracle was trying to get the bind variable value from the list when it was issued at the very first time after the database was started and never looked into the current value set. So, the data set returning was huge...
Well, time to disable this feature "bind peeking".
Here is the way to disable it:
There is an Oracle Hidden parameter which allows to disable it and that parameter is
"_optim_peek_user_binds" by default it is enabled.
alter system set "_optim_peek_user_binds" = false scope=both; --> system wide immediate effect and also modifies the spfile
alter session set "_optim_peek_user_binds" = false --> only for the session so that you can test your code.
Good luck with "bind peeking".
Monday, February 2, 2009
Killing a Session in RAC database
Wednesday, January 28, 2009
Single Row table performs better with WHERE clause!!!???
Yeah I know it sounds funny.
But its true.
Had a customer who was reporting slowness in the system and some one performed the AWR reports and found that this sql is doing tremendous Logical I/Os in the system.
So, the request comes to change the SQL to have a where condition so that Oracle can do Index scans instead of FTS!!!
Answer to that request: a very big NO
Since it was doing 1025 buffer gets per execution, they tested with a where clause and the buffer gets value drops down rapidly and thus the request comes in to add where clause.
Well, the mystery is resolved.
This particular table usage shows 1025 USED BLOCKS instead of 1 and thus FTS is doing 1025 buffer gets every time the data is read.
Why the usage is shows 1025??? No answer. Well, pretty simple reason. Some one must of performed heavy insert and then deleted the rows by keeping only the required row and thus the high water mark stays at 1025.
Solution provide was: take the backup up of the record and insert it back by truncating the table and then run the stats to see if FTS still does 1025 buffer gets.
Hurray, it only does 5 now…. Yeah… the problem is resolved.
So you still wants add where clause to a single row table SQL? Naa…. I guess we are fine….