Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

rekharaghuram
from rekharaghuram More from this publisher
05.11.2015 Views

CHAPTER 5 ■ ■ ■ Oracle Processes We’ve reached the last piece of the architecture puzzle. We’ve investigated the database and the set of physical files that constitute a database. In covering the memory used by Oracle, we’ve looked at one half of an instance. The last remaining architectural issue to cover is the set of processes that constitute the other half of the instance. Each process in Oracle will perform a particular task or set of tasks, and each will have internal memory (PGA memory) allocated by it to perform its job. An Oracle instance has three broad classes of processes: • Server processes: These perform work based on a client’s request. We have already looked at dedicated and shared servers to some degree. These are the server processes. • Background processes: These are the processes that start up with the database and perform various maintenance tasks, such as writing blocks to disk, maintaining the online redo log, cleaning up aborted processes, and so on. • Slave processes: These are similar to background processes, but they are processes that perform extra work on behalf of either a background or a server process. Some of these processes, such as the database block writer (DBWn) and the log writer (LGWR), have cropped up already, but here we’ll take a closer look at the function of each, and what each does and why. ■Note When I use the term “process” in this chapter, consider it to be synonymous with the term “thread” on operating systems where Oracle is implemented with threads (such as Windows). In the context of this chapter, I use the term “process” to cover both processes and threads. If you are using an implementation of Oracle that is multiprocess, such as you see on UNIX, the term “process” is totally appropriate. If you are using a single-process implementation of Oracle, such as you see on Windows, the term “process” will actually mean “thread within the Oracle process.” So, for example, when I talk about the DBWn process, the equivalent on Windows is the DBWn thread within the Oracle process. 155

156 CHAPTER 5 ■ ORACLE PROCESSES Server Processes Server processes are those that perform work on behalf of a client session. They are the processes that ultimately receive and act on the SQL statements our applications send to the database. In Chapter 2, we briefly touched on two connection types to Oracle, namely the following: • Dedicated server, whereby you get a dedicated process on the server for your connection. There is a one-to-one mapping between a connection to the database and a server process or thread. • Shared server, whereby many sessions share a pool of server processes spawned and managed by the Oracle instance. Your connection is to a database dispatcher, not to a dedicated server process created just for your connection. ■Note It is important to understand the difference between a connection and a session in Oracle terminology. A connection is just a physical path between a client process and an Oracle instance (e.g., a network connection between you and the instance). A session, on the other hand, is a logical entity in the database, where a client process can execute SQL and so on. Many independent sessions can be associated with a single connection, and these sessions can even exist independently of a connection. We will discuss this further shortly. Both dedicated and shared server processes have the same job: they process all of the SQL you give to them. When you submit a SELECT * FROM EMP query to the database, an Oracle dedicated/shared server process parses the query and places it into the Shared pool (or finds it in the Shared pool already, hopefully). This process comes up with the query plan, if necessary, and executes the query plan, perhaps finding the necessary data in the buffer cache or reading the data from disk into the buffer cache. These server processes are the workhorse processes. Many times, you will find these processes to be the highest consumers of CPU time on your system, as they are the ones that do your sorting, your summing, your joining—pretty much everything. Dedicated Server Connections In dedicated server mode, there will be a one-to-one mapping between a client connection and a server process (or thread, as the case may be). If you have 100 dedicated server connections on a UNIX machine, there will be 100 processes executing on their behalf. Graphically it looks as shown in Figure 5-1.

CHAPTER 5<br />

■ ■ ■<br />

<strong>Oracle</strong> Processes<br />

We’ve reached the last piece of the architecture puzzle. We’ve investigated the database <strong>and</strong><br />

the set of physical files that constitute a database. In covering the memory used by <strong>Oracle</strong>,<br />

we’ve looked at one half of an instance. The last remaining architectural issue to cover is the<br />

set of processes that constitute the other half of the instance.<br />

Each process in <strong>Oracle</strong> will perform a particular task or set of tasks, <strong>and</strong> each will have<br />

internal memory (PGA memory) allocated by it to perform its job. An <strong>Oracle</strong> instance has<br />

three broad classes of processes:<br />

• Server processes: These perform work based on a client’s request. We have already<br />

looked at dedicated <strong>and</strong> shared servers to some degree. These are the server processes.<br />

• Background processes: These are the processes that start up with the database <strong>and</strong> perform<br />

various maintenance tasks, such as writing blocks to disk, maintaining the online<br />

redo log, cleaning up aborted processes, <strong>and</strong> so on.<br />

• Slave processes: These are similar to background processes, but they are processes that<br />

perform extra work on behalf of either a background or a server process.<br />

Some of these processes, such as the database block writer (DBWn) <strong>and</strong> the log writer<br />

(LGWR), have cropped up already, but here we’ll take a closer look at the function of each, <strong>and</strong><br />

what each does <strong>and</strong> why.<br />

■Note When I use the term “process” in this chapter, consider it to be synonymous with the term “thread”<br />

on operating systems where <strong>Oracle</strong> is implemented with threads (such as Windows). In the context of this<br />

chapter, I use the term “process” to cover both processes <strong>and</strong> threads. If you are using an implementation<br />

of <strong>Oracle</strong> that is multiprocess, such as you see on UNIX, the term “process” is totally appropriate. If you are<br />

using a single-process implementation of <strong>Oracle</strong>, such as you see on Windows, the term “process” will actually<br />

mean “thread within the <strong>Oracle</strong> process.” So, for example, when I talk about the DBWn process, the<br />

equivalent on Windows is the DBWn thread within the <strong>Oracle</strong> process.<br />

155

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!