Testing Syntax Highlighter….

I am not happy with the technical code part that I post over here. Though I know that I have to use some syntax highlighter but I just behaved lazy and didn’t try even to search for one. As like always, Sidhu came as a rescue and asked me install Syntax Highlighter which is a wordpress plugin. I am going to give it a try and see how it shows my code. So this is just a test post for checking the code and the plugin :-) .

SQL> set long 10000000
SQL> set longchunksize 10000000
SQL> set linesize 200
SQL> select dbms_sqltune.report_sql_monitor from dual;
SQL>select count(*) from test;

  COUNT(*)
———-
   1101904

Hope the highlighting is not over-done :-) !

,

6 Comments

Real Time SQL Monitoring, A Goodie Of 11g….

Oracle’s newest database release 11g is having lots of goodies stored in it. Since now even the release 2 of it, (11.2.0.1) is also out, the number of goodies has just gone more higher! There are some things which are really very nice and are worth checking at least for once. This post is just about one of those goodies. The idea of this post is not about a new invention but about the introduction a worth-to-know kind of feature introduced with the Oracle 11g. Interested, okay keep on reading then :-) .

Its always asked by the people who are involved in the query tuning that there should be something which should tell them the current statistics of the query, right at that time when the query is actually running! This kind of monitoring, if available, can help a lot in finding out that out of all the access paths, which one is taking more time  in addition to the time spent in the execution of various steps of the query. Also, there is one question which I am asked all the time that from where the query execution starts in the execution plan? The answer of that can be given looking at the execution plan though but if there can be something which can show us the same when the query is still “alive”, I guess that information can help in both understanding the execution pathway of the query and also can come handy in the troubleshooting part. I am not sure that is there is some tool which can do this kind of task ( if you know, please do post the name of it in the comments) but I believe, there is nothing which I should be worried about now since from 11g release 1, Oracle has given a solution for this with the Real Time SQL Monitoring!

Real-time sql monitoring does exactly what it says, it monitors a query when its actually running. The monitoring information gives a wide information about the query state that whether its over and some more general information about the query. It also brings out the information of the execution plan of the query and the statistics like that how much time is spent by each access path in the plan, also including the cost incurred at that step. This also shows with a nice arrow (->) marker that which step is executing at the moment when the query is still actually running!

Real time monitoring is enabled through the parameter CONTROL_MANAGEMENT_PACK_ACCESS which should be set to the value DIAGNOSTIC+TUNING( default) . In addition to it, the parameter STATISTICS_LEVEL is set to either ALL or TYPICAL(default) . If oracle finds out that the there is delay of more than 5 seconds happening for the query, it can monitor that query. The monitoring information is stored in two new views V$SQL_MONITOR and V$SQL_PLAN_MONITOR. V$SQL_MONITOR view would get populated when the monitoring of the query would start.

The monitoring is recorded through the package DBMS_SQLTUNE’s function, REPORT_SQL_MONITOR which does offer couple of switches that can help in getting the desired output needed to troubleshoot the query’s performance issues. The description of the entire number of options offered by the function is in the link given already. Let’s try to use this function to monitor a simple query. For this purpose, we would be using two sessions where one would be running the query which we want to monitor and the other would be executing the function which would capture the query’s information. First, we prepare the session that is supposed to monitor the running query,

Session-1>>

SQL> set long 10000000
SQL> set longchunksize 10000000
SQL> set linesize 200
SQL> select dbms_sqltune.report_sql_monitor from dual;

 

Now, we shall write a very simple query in the session 2 of ours which we would execute and than monitor it from the first session.

Session-2>>

SQL@AMAN>select count(*) from test;

  COUNT(*)
———-
   1101904

 

Since the query result set is not that much large, the query gets complete in a very less time but still it did take long enough so that Oracle could monitor it. After the query’s execution got over, this is what was reported for it through the monitoring.

Session-1>>

SQL@SYS>select dbms_sqltune.report_sql_monitor from dual;

REPORT_SQL_MONITOR
———————————————————————————————————————————-
———————————————————————-
SQL Monitoring Report

SQL Text
———————————————————————————————————————————-
————————————————-
select count(*) from test
———————————————————————————————————————————-
————————————————-

Global Information
Status              :  DONE (ALL ROWS)
Instance ID         :  1
Session ID          :  131
SQL ID              :  7b2twsn8vgfsc
SQL Execution ID    :  16777216
Plan Hash Value     :  1950795681
Execution Started   :  03/04/2010 23:03:28
First Refresh Time  :  03/04/2010 23:03:31
Last Refresh Time   :  03/04/2010 23:03:35

——————————————————————–
| Elapsed |   Cpu   |    IO    |  Other   | Fetch | Buffer | Reads |
| Time(s) | Time(s) | Waits(s) | Waits(s) | Calls |  Gets  |       |
——————————————————————–
|    6.56 |    0.13 |     6.38 |     0.06 |     1 |  23976 | 16112 |
——————————————————————–

SQL Plan Monitoring Details

| Id |      Operation       | Name |  Rows   | Cost |   Time    | Start  | Starts |   Rows   | Activity  |   Activity Detail    |
|    |                      |      | (Estim) |      | Active(s) | Active |        | (Actual) | (percent) |      (sample #)      |
================================================================|  0 | SELECT STATEMENT     |      |         | 4655 |         1 |     +7 |      1 |        1 |        |                 |
|  1 |   SORT AGGREGATE     |      |       1 |      |         1 |     +7 |      1 |        1 |        |                 |
|  2 |    TABLE ACCESS FULL | TEST |   1097K | 4655 |         6 |     +2 |      1 |    1102K |    100.00 | direct path read (6) |
==================================================================

We can see that a lot of information is captured through the monitoring for us! The sections which presents the interesting outputs are Activity(percent) and Activity Detail(sample#) . The Acitivity percent shows that in terms of DB time, how much time was spent by each access path of the query and the Activity Details shows the detailed information about that activity. For our case, the biggest (and the only active) activity was table access full and this did happen through the Direct Path Read! Furthermore, you can even control the monitoring through two hints as well, MONITOR and NO_MONITOR! And last but certainly not the least, the real time monitoring is also a part of EM which means all of this can be done through nice and shiny colorful EM screens as well. Now that’s cool!

I believe that its a really useful feature! Once again, the idea of this post was not post something “internal” but just to bring this feature in front of you. If you already knew about it, cool, feel free to add more information about this feature over here via the comments. If you didn’t know about it before, well, now you know so enjoy it to the fullest :-D . Oh and BTW, you can read about this feature in detail from here.

, ,

2 Comments

Segment Checking Using DBV….

I have seen many people talking about the Database Verify(DBV) utility that it can be only used for the physical database check for any sort of corruptions( which is true too). That’s correct to say that the use of the DBV is to check (mandatorily) the data blocks so it can be used only to check the data files.

I have just got a question which did raise a doubt that somewhere its mentioned that the DBV can be “only” used to do the “logical corruption” check as well, how? Well, first of all , the statement itself is not correct. The DBV can be certainly used to check the physical corruption of a block and that’s what I believe most of us know about DBV as well too. So what about this logical corruption? Ain’t we suppose to use Flashback technology for it? Well, to answer these questions, we first of all have to understand what does it mean by “logical corruption” ?

First , what’s a physical corruption? It means that the underlying place where the block was sitting, itself is corrupted. The error normally would arise because of a faulty media or a bad sector over the media which essentially would physically corrupt the block, making it impossible for oracle to access it.And if you do find a block physically corrupted, the very first step before you attempt to recover the block would be that you replace the underlying media first.  Once the media is replaced, the underlying block can be recovered using the Block Recover command (10g) or Recover command(11g) !

The perception that I have seen most of the times in my sessions is that when someone mentions “logical corruption”, he only means a DML corrupting data “logically” , for example all salaries getting updated to 0 by someone in one single Update command! Right? Wrong! This is not “logical corruption” but its “logical data corruption” and certainly for this, the Flashback technology is well verse to be used! So what the heck is the “logical corruption” of a block is ? Well, simply put and in the first place, the block is physically fine which means that the physical location where the block is located is perfectly fine and there are absolutely no issues for Oracle to read the block! But despite that, there is some inconsistency  in the block which is making it marked as corrupted and that’s not related to the physical allocation of the block!

For example, if there is an index entry that should point to a data block, is found to be null i.e it stores an entry pointing to nowhere is an example of logical corruption of the block! The block would be fine in terms of physical aspects but still, its termed as corrupted “logically” by oracle! If there is a row entry mismatch found in the block, oracle reports internal error, ora-600 with the argument, [KDSGRP1], which means that there was a mismatch found in the row entries of the block. This kind of corruption would normally happen on its own and there are not set rules which would make it come! When you hit logical corruption, the block from Oracle’s side is completely fine and is fully accessible, yet the block is corrupted internally! This kind of corruption can be checked with the DBV command supplying it the information about the object whose blocks you want to verify. Obviously, this detection would be done below the high water mark of the segment, covering only those block which were formatted either now or in the past some time! The new or unformatted won’t have anything to do with the lgocial corruption!

To call DBV for the segment check, you need to pass minimally the user information (login credentials) of the user with the segment information which would comprise of the Tablespace Number, Relative file Number of the tablespace containing the block and the header block of the object! All this information can be picked up using the V$tablespace and dba_segments views. Other than that, in the Sys schema, you can find the view with the name Sys_user_segs which would also show the same to you! Shown below is a small snippet which is about creating an object and thus checking its information from both the views and finally using that info in the DBV command! Please note that the segment identification information passed in the command is comprising of the tablespace id, relative file number of the object and the header block of the object!


SQL> select * from v$version; 

BANNER   --------------------------------------------------------------------------    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production    PL/SQL Release 11.1.0.6.0 - Production    CORE    11.1.0.6.0      Production    TNS for 32-bit Windows: Version 11.1.0.6.0 - Production    NLSRTL Version 11.1.0.6.0 - Production 

SQL> drop table e purge     2  ; 

Table dropped. 

SQL> create table e as select * from scott.emp; 

Table created. 

SQL> exec dbms_stats.gather_table_stats(user,'E'); 

PL/SQL procedure successfully completed.

SQL> select segment_name, tablespace_name, header_file, header_block     2  from dba_segments      3  where segment_name='E'; 

SEGMENT_NAME   -------------------------------------------------------------------------    TABLESPACE_NAME                HEADER_FILE HEADER_BLOCK    ------------------------------ ----------- ------------    E    USERS                                    4          395 

SQL> select ts#,name from v$tablespace where name='USERS'; 

       TS# NAME   ---------- ------------------------------             4 USERS 

SQL> exit

C:\>dbv userid=aman/aman segment_id=4.4.395 

DBVERIFY: Release 11.1.0.6.0 - Production on Thu Mar 4 00:34:59 2010 

Copyright (c) 1982, 2007, Oracle.  All rights reserved. 

DBVERIFY - Verification starting : SEGMENT_ID = 4.4.395 

DBVERIFY - Verification complete 

Total Pages Examined         : 8   Total Pages Processed (Data) : 1    Total Pages Failing   (Data) : 0    Total Pages Processed (Index): 0    Total Pages Failing   (Index): 0    Total Pages Processed (Other): 6    Total Pages Processed (Seg)  : 1    Total Pages Failing   (Seg)  : 0    Total Pages Empty            : 0    Total Pages Marked Corrupt   : 0    Total Pages Influx           : 0    Total Pages Encrypted        : 0    Highest block SCN            : 1094559 (0.1094559) 

C:\>

As you can see that there won’t be anything mentioned by the DBV that the corruption is due to a physical corruption or a logical corruption! That’s why, to be ensured, its better to use Rman’s validate command which can check the blocks for physical and logical corruption!

So what’s the conclusion? Well, the conclusion is that “logical data corruption” is not the same as “logical block corruption” and DBV is not meant for only checking the physical corruption of the blocks within the data file and can be used the blocks of a segment as well!

And all of this is documented( okay may be not all ) in the official documentation,

http://download.oracle.com/docs/cd/E11882_01/server.112/e10701/dbverify.htm#i1006970

Hope this helps :-) !

7 Comments

Want To Become Oracle Certified? Do It ASAP Because….

Oracle University has announced that they are going to increase the prices of their exams from March 1,2010! You can read the complete information from this post.

Well, this was about the announcement, now a little rant! I am not sure that whether this price hike is actually correct or not? If one looks at the prices of the courses, combines it with the logistic charges, add to it the prices of the exams, the sum total becomes sky high! And this is when the exam fee is still the same. So when the exam fee would be increased, I am not sure how many would be really interested to take up the exams since I hear all the time at the moment even that the prices are very high! Agreed that the price hike would vary from country to country(which I don’t understand why but that’s another rant to talk about I guess) still, it would effect in an overall manner a lot! Not sure what’s good is going to come out from this but I believe its going to demoralize those new aspirants who want to get certified! I just hope that it won’t happen because doesn’t matter what anyone would say, Oracle Certification program is still is the best way to learn and demonstrate one’s passion about learning Oracle! Okay rant over!!

If you want to get certified and are delaying it, probably the time has come that you speed up your preparation process and write the exams as soon as possible! And this makes me recall that I need to do the same as well :-( !

,

1 Comment

Blog Upgrade, Wordpress 2.9.2….

I just saw that the update is available for the Wordpress for the latest 2.9.2 version. Just finished the upgrade of the blog. If you can see this post, it means all went well :-) .

No Comments

Confused About DataGuard, Issues With It, Share/Discuss/Get Clarifications At….

Data Guard forum at OTN forums! It just has come up and based on the discussion happened here, I believe its the fruit of the efforts done by the product manager of Data Guard Larry Carpenter who is also the lead author of Data Guard Handbook from Oracle Press! I am quite active over OTN forums and based on my experience over there, I can say with complete trust that alike other forums like Database General and many more, this would also help Oracle community immensely! Another bookmark added to my daily-visit sites :-) !

10 Comments

Redo & Undo, Partners In Crime Talked About Yet Again….

Anyone who does know about Oracle db and its working even the slightest bit would have heard about these two words for sure, Redo and Undo! Both make Oracle db what it is, a very robust data engine and also come out as one of the most complex algorithms to understand within the same. Almost all the time, there is some confusion that’s there about these two and I am sure, both will be a very hot topic of discussion for many many years yet to come!

I am quite active on OTN Forums ( and no that’s not an excuse of being less active here) and at times, there are some very interesting questions which do pop up there. One such question about Redo, which obviously would include Undo as well did come out few days back over this thread, why not use Redo log for consistent read. Now, it shouldn’t come out as a surprise that why Redo can’t be used if one understands the way it works but it was still a very interesting topic to jump into since the way Oracle db works is one of my favorite areas. So I did try to explain it somewhat. If you think that you don’t know the answer or even if you know you do, I would welcome you to read the thread! As like always, any corrections wherever needed and possible are most welcome!

Though the thread went to great lengths, still I fee that the underlying answer was not really what it should had been. I am sure the reason is my not-so-deep understanding about Oracle db only since I was the one who did give maximum replies there. But I guess, the topic was actually good because of which, Jonathan Lewis, probably the best and the most knowledgeable person over this planet about Oracle, did pick the question and gave the actual (and an awesome one) and very detailed answer over here. I would recommend you to read the complete blog post which clears the concept completely that why Redo should NOT be used for read consistency and Undo should be! Thanks so much Jonathan for such a brilliant explanation!

I am pretty busy at the moment( and no, this is also not the reason for being less active here) because there is a very important writing assignment I am working over but I shall try to write soon about some of these basic concepts over here! Hope that “soon” happens soon :-) !

,

No Comments

Blog Upgrade, Wordpress 2.9.1….

I have just upgraded my blog to 2.9.1 version. In addition to it, I have upgraded few of my plugins as well. I must say, I am amazed at the speed at which all it happened! Keep it up Wordpress and also publish how you do it so that we can give some feedback to Oracle as well for the same :-) .

Happy upgrading :-) .

No Comments

Book Review, Middleware Management with Oracle Enterprise Manager Grid Control 10g R5….

We are entering into the DBA 2.0 era or I should say we have already entered quite deeply into it! And in this era, there is more and more penetration of graphical interfaced tools. Enterprise Manager (EM) from Oracle has evolved a lot in the last few years. The biggest change in EM came when it became web based from 10g onwards and was divided into two categories, Database Console( DBC) the free version and Grid Console(GC) , the paid and full blown version! Where DBC helps managing a single instance very well, there are limitations in it and the ability to manage one instance per console is the biggest one! GC completes that limitation and offers much more than just managing database! With so many goodies in GC, it becomes a deep topic which needs good mentoring to be done about it. Yes, there is a massive wealth of information in Oracle documentation about the subject, but if there is something which explains things in a more organized manner, I guess, that would make things much easier! And luckily Debu Panda ( here is the link to his personal site ) and Arvind Maheshwari has given us just that only with their book, Middleware Management with Oracle Enterprise Manager Grid Control 10g R5 which is released via Packt Publishing.

The book covers to a great depth the concepts of GC and how it works. After building up the base, the authors move us to the usage of GC which includes its installing it and further more, the deployment of Application Server and Weblogic Server. Going further enlightens us with various techniques and best practices of deployments using GC. There is an ample amount of information about the installation as well. The book covers the details in a well versed manner and the language chosen by authors is also very simple and easy to understand which makes it valued addition to the list of those oracle books, which one must have for a regular reference! Over all, a good write up and a recommended one!

, ,

No Comments

Grant ‘Very Happy 2010’ To All….

Yes its a wrong syntax if we see it from a technical point of view but it sounds perfect still! Another year is ending and a new year is just on the doorsteps. I wish you all who come here a very happy and prosperous 2010 and the best of the holiday season! Hope this year brings the best of everything for you and becomes one of the most memorable and happening years of your life! Have a great new year evening either tonight or tomorrow night( depending on where you are on this planet) and have lots of fun :-) .

2 Comments