正文

Difference Between Connections, Sessions and Processes

(2010-09-22 12:58:05) 下一個

***Sessions***

Connect to database through sqlplus create a session. 

A session can be forced to be terminated with the alter system kill session statement. 

Note: The alter system kill session statement will not make the session go away until it times out or it tries to issue another statement. However, pmon will rollback the work done by the session.

The server process waits then until the client tries to execute another statement to send it a ORA-03113 EOF on communication channel or "packet write failure". This is why killed sessions still show up in the v$session view.  

However, if dead client detection (or is it dead connection detection?) is enabled, the session is removed as soon as the expiry time is reached.

To immediately release the locks (immediatly meaning: after the session's rollback), one should use kill -9 on unix or orakill on unix.  

If there is a logoff trigger, it won't be executed for the killed session.  

***Processes***

A process is a physical process or thread. A process will be used by a session to execute statements. 

Two kind of process in oracle:

1. back ground processes: SMON, PMON, RECO, ARCH, CKPT, EMNn, DBWR, etc..... 

2. user processes: dedicated servers or shared server.

***Connections***
A connection is a "physical circuit", a pathway to a database.  You can be connected to a database yet have 0 or 1 or MORE sessions going on that connection.

Sometimes there is a one to one relationship between CONNECTION->SESSION->PROCESS (eg: a normal dedicated server connection).  Sometimes there is a one to many from connection to sessions (eg: like autotrace, one connection, two sessions, one process).  

 In oracle, The parameters SESSIONS and PROCESSES determine the size of two arrays in the SGA. 

If you try to create more sessions on an instance than specified by the SESSIONS  parameter, you will get an ORA-00018: maximum number of sessions exceeded.

If you try to create more processes on an instances than specified by the PROCESSES prameter, you wil get an ORA-00020: maximum number of processes exceeded. 

The number of sessions and processes on your instance can been seen using a COUNT(*) against V$PROCESS and V$SESSION. Your job is to determine resonable values, so your users can continue to work without getting neither ORA-18 nor ORA-20 during normal conditions. (A run away job, that keeps starting new sessions is not a normal condition, and it should be stopped by ORA-18 or ORA-20 whichever happens first).

You can join the two V$-views using the columns V$SESSION.PADDR and V$PROCESS.ADDR.

It is quite normal to see a 1:1 relationship between processes and sessions. However one OCI-program can create multiple sessions belonging to one process. Users of Oracle Portal will experience this behaviour. 

The default value for SESSIONS is 1.1*PROCESSES + 5.  It is appropriate for some databases and inappropriate for others (e.g. Oracle Portal).

[ 打印 ]
閱讀 ()評論 (0)
評論
目前還沒有任何評論
登錄後才可評論.