Find and Analyze Particular Session in Oracle
Find and Analyze Particular Session in Oracle
The subject might look trivial for seniors, but I have seen most of the DBA’s struggle to find a session if
someone comes to you and seeking help about that oracle session. I have seen many DBA’s struggle a
lot when there are no tools available for them to monitor the database.
Let’s say some applications team reaches you to find the oracle session that application connected and
asking to kill the session related to those applications.
If you rely on pure custom SQL’s, here is the place to find how to use them and analyze those sql
sessions.
If you know SQL, then it might be easy to find any session from gv$session. Let’s say if you don’t have
SQL, then you might need to look into the below columns in GV$session.
MACHINE - The name of the machine where the client is running. If you are connected to the database
using your machine, then it will show your machine name in this column.
MODULE – Name of the currently executing module. It shows “SQL Developer” if you connected to the
database using “SQL Developer”.
PROGRAM – OS program name.
OSUSER – OS username of the machine.
USERNAME – Oracle Username that connected.
CLIENT_IDENTIFIER – Client identifier of the session
PROCESS – OS process of the machine
LOGON_TIME – Logon time of the session.
You should get minimum details of machine and username from the application team so that you can
check against those columns in GV$Session.
Next step is to interpret module and program for that particular process. For an instance, for
concurrent programs the module will be the short name of the concurrent program executable and
program will show the manager short name.
Finally, the easiest way to find any process is just to grep the process number in the machine name and
you can check whether it belongs to frmweb(forms) process or java (concurrent program) or anything
else. The above columns are more than enough to interpret the session details.
For example,
By looking at this process, we could understand this process belongs to form sessions. (As it shows
frmweb). Now, that is easy. How about the following one?
By looking at the process, one may have many confusions on what this process about. Is this related to
any java process or any other application process? Well if you read the process line by line, you could
see -Dconc_queue_id= 1140. Looking at this, it gives us some hint about concurrent manager related
process. Let get this details from FND_CONCURRENT_QUEUES using the queue id. Now you will get the
manager name.
CONCURRENT_QUEUE_ID CONCURRENT_QUEUE_NAME
------------------- ------------------------------
1140 WFMLRSVC
Now, this does look short name of the concurrent manager. Well, let’s query from
FND_CONCURRENT_QUEUES_VL view which will give the concurrent manager name.
USER_CONCURRENT_QUEUE_NAME CONCURRENT_QUEUE_ID
-------------------------------------------------- -------------------
Workflow Mailer Service 1140
There you go. This process belongs to “Workflow Mailer Service”. If you still need to verify it, let us get
that verified too from the front end.
Arun Kumar K
Once you interpret the session, you will be able to easily make some decision about the oracle session
or process for next course of action. Now you have learned to identify the unix process and oracle
session.
Let us see what oracle session is doing in the database.
Idle Session not doing anything and it is waiting to be given some work
Processing Doing some productive work and it is running on CPU
Waiting Waiting for something such as lock on the object to be released.
Idle – The session is not slow rather it has nothing to do and it is simply idle.
Processing – It is neither waiting nor idle. It is doing some productive work.
Waiting – The session is waiting for some work to be completed such as lock to be released so that this
session can run.
Now, we understood the state of the session and that can be interpreted in STATE column in
V$SESSION.
To get meaningful details after referring the state column, you should combine with EVENT column to
know about what the session is doing.
Event column will have many event details and give you information what the session is waiting for.
For example, STATE column is showing Waiting and EVENT column shows “enq: TX - row lock
contention” which means it is waiting for some object lock to be released. Once released, it will start
doing productive work.
Another example is STATE column showing “WAITED KNOWN TIME” and EVENT column shows
“SQL*Net message from client” which means the session is doing productive work now and it was
waiting for some data to be returned from client.
Arun Kumar K
Therefore, now you have almost all details of the session. Ah! One thing is missing. How long the
session is waiting / waited and what it is doing? To get these details, we need to look into
SECONDS_IN_WAIT column of GV$SESSION.
We must look at the STATE column first to identify the session is waiting or doing some work and then
look at the SECONDS_IN_WAIT column to find the length of the wait time. When the session of the
STATE column indicates any productive work (STATE column has other than WAITING), then we must
look at the WAIT TIME in GV$SESSION. Note that WAIT TIME in GV$SESSION is shown in centiseconds
(hundredths of a second). You must divide the WAIT TIME value by 100 to get timing details in
SECONDS.
Conclusion
In this article presented how to find a particular session and examine whether it is doing productive or
non-productive work.
Also, the length of the time of session doing productive or non-productive work. It is easy to
understand any process of oracle session and it is very crucial to analyze the oracle session before taking
any action on that particular session.