Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005
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.
- Page 150 and 151: CHAPTER 3 ■ FILES 105 USER is "SY
- Page 152 and 153: CHAPTER 3 ■ FILES 107 Flashback L
- Page 154 and 155: CHAPTER 3 ■ FILES 109 of the requ
- Page 156 and 157: CHAPTER 3 ■ FILES 111 IMPDP, howe
- Page 158 and 159: CHAPTER 3 ■ FILES 113 tkyte@ORA10
- Page 160 and 161: CHAPTER 4 ■ ■ ■ Memory Struct
- Page 162 and 163: CHAPTER 4 ■ MEMORY STRUCTURES 117
- Page 164 and 165: CHAPTER 4 ■ MEMORY STRUCTURES 119
- Page 166 and 167: CHAPTER 4 ■ MEMORY STRUCTURES 121
- Page 168 and 169: CHAPTER 4 ■ MEMORY STRUCTURES 123
- Page 170 and 171: CHAPTER 4 ■ MEMORY STRUCTURES 125
- Page 172 and 173: CHAPTER 4 ■ MEMORY STRUCTURES 127
- Page 174 and 175: CHAPTER 4 ■ MEMORY STRUCTURES 129
- Page 176 and 177: CHAPTER 4 ■ MEMORY STRUCTURES 131
- Page 178 and 179: CHAPTER 4 ■ MEMORY STRUCTURES 133
- Page 180 and 181: CHAPTER 4 ■ MEMORY STRUCTURES 135
- Page 182 and 183: CHAPTER 4 ■ MEMORY STRUCTURES 137
- Page 184 and 185: CHAPTER 4 ■ MEMORY STRUCTURES 139
- Page 186 and 187: CHAPTER 4 ■ MEMORY STRUCTURES 141
- Page 188 and 189: CHAPTER 4 ■ MEMORY STRUCTURES 143
- Page 190 and 191: CHAPTER 4 ■ MEMORY STRUCTURES 145
- Page 192 and 193: CHAPTER 4 ■ MEMORY STRUCTURES 147
- Page 194 and 195: CHAPTER 4 ■ MEMORY STRUCTURES 149
- Page 196 and 197: CHAPTER 4 ■ MEMORY STRUCTURES 151
- Page 198 and 199: CHAPTER 4 ■ MEMORY STRUCTURES 153
- Page 202 and 203: CHAPTER 5 ■ ORACLE PROCESSES 157
- Page 204 and 205: CHAPTER 5 ■ ORACLE PROCESSES 159
- Page 206 and 207: CHAPTER 5 ■ ORACLE PROCESSES 161
- Page 208 and 209: CHAPTER 5 ■ ORACLE PROCESSES 163
- Page 210 and 211: CHAPTER 5 ■ ORACLE PROCESSES 165
- Page 212 and 213: CHAPTER 5 ■ ORACLE PROCESSES 167
- Page 214 and 215: CHAPTER 5 ■ ORACLE PROCESSES 169
- Page 216 and 217: CHAPTER 5 ■ ORACLE PROCESSES 171
- Page 218 and 219: CHAPTER 5 ■ ORACLE PROCESSES 173
- Page 220 and 221: CHAPTER 5 ■ ORACLE PROCESSES 175
- Page 222 and 223: CHAPTER 5 ■ ORACLE PROCESSES 177
- Page 224 and 225: CHAPTER 5 ■ ORACLE PROCESSES 179
- Page 226 and 227: CHAPTER 5 ■ ORACLE PROCESSES 181
- Page 228 and 229: CHAPTER 6 ■ ■ ■ Locking and L
- Page 230 and 231: CHAPTER 6 ■ LOCKING AND LATCHING
- Page 232 and 233: CHAPTER 6 ■ LOCKING AND LATCHING
- Page 234 and 235: CHAPTER 6 ■ LOCKING AND LATCHING
- Page 236 and 237: CHAPTER 6 ■ LOCKING AND LATCHING
- Page 238 and 239: CHAPTER 6 ■ LOCKING AND LATCHING
- Page 240 and 241: CHAPTER 6 ■ LOCKING AND LATCHING
- Page 242 and 243: CHAPTER 6 ■ LOCKING AND LATCHING
- Page 244 and 245: CHAPTER 6 ■ LOCKING AND LATCHING
- Page 246 and 247: CHAPTER 6 ■ LOCKING AND LATCHING
- Page 248 and 249: CHAPTER 6 ■ LOCKING AND LATCHING
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