In this chapter:
Oracle Database creates server processes to handle the requests of user processes connected to an instance. A server process can be either of the following:
A dedicated server process, which services only one user process
A shared server process, which can service multiple user processes
Your database is always enabled to allow dedicated server processes, but you must specifically configure and enable shared server by setting one or more initialization parameters.
Figure 5-1, "Oracle Database Dedicated Server Processes" illustrates how dedicated server processes work. In this diagram two user processes are connected to the database through dedicated server processes.
In general, it is better to be connected through a dispatcher and use a shared server process. This is illustrated in Figure 5-2, "Oracle Database Shared Server Processes". A shared server process can be more efficient because it keeps the number of processes required for the running instance low.
In the following situations, however, users and administrators should explicitly connect to an instance using a dedicated server process:
To submit a batch job (for example, when a job can allow little or no idle time for the server process)
To use Recovery Manager (RMAN) to back up, restore, or recover a database
To request a dedicated server connection when Oracle Database is configured for shared server, users must connect using a net service name that is configured to use a dedicated server. Specifically, the net service name value should include the
SERVER=DEDICATED clause in the connect descriptor.
See Also:Oracle Database Net Services Administrator's Guide for more information about requesting a dedicated server connection
Consider an order entry system with dedicated server processes. A customer phones the order desk and places an order, and the clerk taking the call enters the order into the database. For most of the transaction, the clerk is on the telephone talking to the customer. A server process is not needed during this time, so the server process dedicated to the clerk's user process remains idle. The system is slower for other clerks entering orders, because the idle server process is holding system resources.
Shared server architecture eliminates the need for a dedicated server process for each connection (see Figure 5-2).
In a shared server configuration, client user processes connect to a dispatcher. The dispatcher can support multiple client connections concurrently. Each client connection is bound to a virtual circuit, which is a piece of shared memory used by the dispatcher for client database connection requests and replies. The dispatcher places a virtual circuit on a common queue when a request arrives.
An idle shared server process picks up the virtual circuit from the common queue, services the request, and relinquishes the virtual circuit before attempting to retrieve another virtual circuit from the common queue. This approach enables a small pool of server processes to serve a large number of clients. A significant advantage of shared server architecture over the dedicated server model is the reduction of system resources, enabling the support of an increased number of users.
For even better resource management, shared server can be configured for connection pooling. Connection pooling lets a dispatcher support more users by enabling the database server to time out protocol connections and to use those connections to service an active session. Further, shared server can be configured for session multiplexing, which combines multiple sessions for transmission over a single network connection in order to conserve the operating system's resources.
Shared server architecture requires Oracle Net Services. User processes targeting the shared server must connect through Oracle Net Services, even if they are on the same system as the Oracle Database instance.
See Also:Oracle Database Net Services Administrator's Guide for more detailed information about shared server, including features such as connection pooling and session multiplexing
Database Resident Connection Pooling (DRCP) provides a connection pool in the database server for typical Web application usage scenarios where the application acquires a database connection, works on it for a relatively short duration, and then releases it. DRCP pools "dedicated" servers. A pooled server is the equivalent of a server foreground process and a database session combined.
DRCP complements middle-tier connection pools that share connections between threads in a middle-tier process. In addition, DRCP enables sharing of database connections across middle-tier processes on the same middle-tier host and even across middle-tier hosts. This results in significant reduction in key database resources needed to support a large number of client connections, thereby reducing the database tier memory footprint and boosting the scalability of both middle-tier and database tiers. Having a pool of readily available servers also has the additional benefit of reducing the cost of creating and tearing down client connections.
DRCP is especially relevant for architectures with multi-process single threaded application servers (such as PHP/Apache) that cannot perform middle-tier connection pooling. The database can still scale to tens of thousands of simultaneous connections with DRCP.
Database resident connection pooling is useful when multiple clients access the database and when any of the following apply:
A large number of client connections need to be supported with minimum memory usage.
The client applications are similar and can share or reuse sessions.
Applications are similar if they connect with the same database credentials and use the same schema.
The client applications acquire a database connection, work on it for a relatively short duration, and then release it.
Session affinity is not required across client requests.
There are multiple processes and multiple hosts on the client side.
Using database resident connection pooling provides the following advantages:
Enables resource sharing among multiple middle-tier client applications.
Improves scalability of databases and applications by reducing resource usage.
LOGON triggers fire for every authentication and every time a new session is created in DRCP.
LOGOFF triggers fire on every log off and every time a session is released in DRCP. Therefore, a
LOGOFF trigger fires when a session is terminated due to an idle time limit.
Table 5-1 lists the differences between dedicated server, shared server, and database resident connection pooling.
|Dedicated Server||Shared Server||Database Resident Connection Pooling|
When a client request is received, a new server process and a session are created for the client.
When the first request is received from a client, the Dispatcher process places this request on a common queue. The request is picked up by an available shared server process. The Dispatcher process then manages the communication between the client and the shared server process.
When the first request is received from a client, the Connection Broker picks an available pooled server and hands off the client connection to the pooled server.
If no pooled servers are available, the Connection Broker creates one. If the pool has reached its maximum size, the client request is placed on the wait queue until a pooled server is available.
Releasing database resources involves terminating the session and server process.
Releasing database resources involves terminating the session.
Releasing database resources involves releasing the pooled server to the pool.
Memory requirement is proportional to the number of server processes and sessions. There is one server and one session for each client.
Memory requirement is proportional to the sum of the shared servers and sessions. There is one session for each client.
Memory requirement is proportional to the number of pooled servers and their sessions. There is one session for each pooled server.
Session memory is allocated from the PGA.
Session memory is allocated from the SGA.
Session memory is allocated from the PGA.
Consider an application in which the memory required for each session is 400 KB and the memory required for each server process is 4 MB. The pool size is 100 and the number of shared servers used is 100.
If there are 5000 client connections, the memory used by each configuration is as follows:
Memory used = 5000 X (400 KB + 4 MB) = 22 GB
Memory used = 5000 X 400 KB + 100 X 4 MB = 2.5 GB
Out of the 2.5 GB, 2 GB is allocated from the SGA.
Database Resident Connection Pooling
Memory used = 100 X (400 KB + 4 MB) + (5000 X 35KB)= 615 MB
The cost of each connection to the broker is approximately 35 KB.
You cannot perform the following activities when connected with pooled servers:
Shut down the database
Stop the database resident connection pool
Change the password for the connected user
Use shared database links to connect to a database resident connection pool
Use Advanced Security Option (ASO) options such as encryption, certificates, and so on
Use migratable sessions on the server side directly by using the OCI_MIGRATE option or indirectly through OCIConnectionPool
DDL statements that pertain to database users in the pool need to be performed carefully, as the pre-DDL sessions in the pool can still be given to clients post-DDL. For example, while dropping users, ensure that there are no sessions of that user in the pool and no connections to the Broker that were authenticated as that user.
Sessions with explicit roles enabled, that are released to the pool, can be later handed out to connections (of the same user) that need the default logon role. Avoid releasing sessions with explicit roles, and instead terminate them.
This section discusses how to enable shared server and how to set or alter shared server initialization parameters. It contains the following topics:
The following initialization parameters control shared server operation:
SHARED_SERVERS: Specifies the initial number of shared servers to start and the minimum number of shared servers to keep. This is the only required parameter for using shared servers.
MAX_SHARED_SERVERS: Specifies the maximum number of shared servers that can run simultaneously.
SHARED_SERVER_SESSIONS: Specifies the total number of shared server user sessions that can run simultaneously. Setting this parameter enables you to reserve user sessions for dedicated servers.
DISPATCHERS: Configures dispatcher processes in the shared server architecture.
MAX_DISPATCHERS: Specifies the maximum number of dispatcher processes that can run simultaneously. This parameter can be ignored for now. It will only be useful in a future release when the number of dispatchers is auto-tuned according to the number of concurrent connections.
CIRCUITS: Specifies the total number of virtual circuits that are available for inbound and outbound network sessions.
See Also:Oracle Database Reference for more information about these initialization parameters
Shared server requires some user global area (UGA) in either the shared pool or large pool. For installations with a small number of simultaneous sessions, the default sizes for these system global area (SGA) components are generally sufficient. However, if you expect a large number of sessions for your installation, you may have to tune memory to support shared server.
See the "Configuring and Using Memory" section of Oracle Database Performance Tuning Guide for guidelines.
Shared server is enabled by setting the
SHARED_SERVERS initialization parameter to a value greater than 0. The other shared server initialization parameters need not be set. Because shared server requires at least one dispatcher in order to work, a dispatcher is brought up even if no dispatcher has been configured. Dispatchers are discussed in "Configuring Dispatchers".
Shared server can be started dynamically by setting the
SHARED_SERVERS parameter to a nonzero value with the
ALTER SYSTEM statement, or
SHARED_SERVERS can be included at database startup in the initialization parameter file. If
SHARED_SERVERS is not included in the initialization parameter file, or is included but is set to 0, then shared server is not enabled at database startup.
SHARED_SERVERSis not included in the initialization parameter file at database startup, but
DISPATCHERSis included and it specifies at least one dispatcher, shared server is enabled. In this case, the default for
DISPATCHERS is included in the initialization file, you cannot start shared server after the instance is brought up by just altering the
DISPATCHERS parameter. You must specifically alter
SHARED_SERVERS to a nonzero value to start shared server.
Note:If you create your Oracle database with Database Configuration Assistant (DBCA), DBCA configures a dispatcher for Oracle XML DB (XDB). This is because XDB protocols like HTTP and FTP require shared server. This results in a
SHARED_SERVERvalue of 1. Although shared server is enabled, this configuration permits only sessions that connect to the XDB service to use shared server. To enable shared server for regular database sessions (for submitting SQL statements), you must add an additional dispatcher configuration, or replace the existing configuration with one that is not specific to XDB. See "Configuring Dispatchers" for instructions.
The SHARED_SERVERS initialization parameter specifies the minimum number of shared servers that you want created when the instance is started. After instance startup, Oracle Database can dynamically adjust the number of shared servers based on how busy existing shared servers are and the length of the request queue.
In typical systems, the number of shared servers stabilizes at a ratio of one shared server for every ten connections. For OLTP applications, when the rate of requests is low, or when the ratio of server usage to request is low, the connections-to-servers ratio could be higher. In contrast, in applications where the rate of requests is high or the server usage-to-request ratio is high, the connections-to-server ratio could be lower.
The PMON (process monitor) background process cannot terminate shared servers below the value specified by
SHARED_SERVERS. Therefore, you can use this parameter to stabilize the load and minimize strain on the system by preventing PMON from terminating and then restarting shared servers because of coincidental fluctuations in load.
If you know the average load on your system, you can set
SHARED_SERVERS to an optimal value. The following example shows how you can use this parameter:
Assume a database is being used by a telemarketing center staffed by 1000 agents. On average, each agent spends 90% of the time talking to customers and only 10% of the time looking up and updating records. To keep the shared servers from being terminated as agents talk to customers and then spawned again as agents access the database, a DBA specifies that the optimal number of shared servers is 100.
However, not all work shifts are staffed at the same level. On the night shift, only 200 agents are needed. Since
SHARED_SERVERS is a dynamic parameter, a DBA reduces the number of shared servers to 20 at night, thus allowing resources to be freed up for other tasks such as batch jobs.
You can decrease the minimum number of shared servers that must be kept active by dynamically setting the
SHARED_SERVERS parameter to a lower value. Thereafter, until the number of shared servers is decreased to the value of the
SHARED_SERVERS parameter, any shared servers that become inactive are marked by PMON for termination.
The following statement reduces the number of shared servers:
ALTER SYSTEM SET SHARED_SERVERS = 5;
SHARED_SERVERS to 0 disables shared server. For more information, see "Disabling Shared Server".
MAX_SHARED_SERVERS parameter specifies the maximum number of shared servers that can be automatically created by PMON. It has no default value. If no value is specified, then PMON starts as many shared servers as is required by the load, subject to these limitations:
The process limit (set by the
PROCESSES initialization parameter)
A minimum number of free process slots (at least one-eighth of the total process slots, or two slots if
PROCESSES is set to less than 24)
Note:On Windows NT, take care when setting
MAX_SHARED_SERVERSto a high value, because each server is a thread in a common process.
The value of
SHARED_SERVERS overrides the value of
MAX_SHARED_SERVERS. Therefore, you can force PMON to start more shared servers than the
MAX_SHARED_SERVERS value by setting
SHARED_SERVERS to a value higher than
MAX_SHARED_SERVERS. You can subsequently place a new upper limit on the number of shared servers by dynamically altering the
MAX_SHARED_SERVERS to a value higher than
The primary reason to limit the number of shared servers is to reserve resources, such as memory and CPU time, for other processes. For example, consider the case of the telemarketing center discussed previously:
The DBA wants to reserve two thirds of the resources for batch jobs at night. He sets
MAX_SHARED_SERVERS to less than one third of the maximum number of processes (
PROCESSES). By doing so, the DBA ensures that even if all agents happen to access the database at the same time, batch jobs can connect to dedicated servers without having to wait for the shared servers to be brought down after processing agents' requests.
Another reason to limit the number of shared servers is to prevent the concurrent run of too many server processes from slowing down the system due to heavy swapping, although
PROCESSES can serve as the upper bound for this rather than
Still other reasons to limit the number of shared servers are testing, debugging, performance analysis, and tuning. For example, to see how many shared servers are needed to efficiently support a certain user community, you can vary
MAX_SHARED_SERVERS from a very small number upward until no delay in response time is noticed by the users.
SHARED_SERVER_SESSIONS initialization parameter specifies the maximum number of concurrent shared server user sessions. Setting this parameter, which is a dynamic parameter, lets you reserve database sessions for dedicated servers. This in turn ensures that administrative tasks that require dedicated servers, such as backing up or recovering the database, are not preempted by shared server sessions.
This parameter has no default value. If it is not specified, the system can create shared server sessions as needed, limited by the
SESSIONS initialization parameter.
CIRCUITS parameter sets a maximum limit on the number of virtual circuits that can be created in shared memory. This parameter has no default. If it is not specified, then the system can create circuits as needed, limited by the
DISPATCHERS initialization parameter and system resources.
DISPATCHERS initialization parameter configures dispatcher processes in the shared server architecture. At least one dispatcher process is required for shared server to work.If you do not specify a dispatcher, but you enable shared server by setting
SHARED_SERVER to a nonzero value, then by default Oracle Database creates one dispatcher for the TCP protocol. The equivalent
DISPATCHERS explicit setting of the initialization parameter for this configuration is:
You can configure more dispatchers, using the
DISPATCHERS initialization parameter, if either of the following conditions apply:
You must configure a protocol other than TCP/IP. You configure a protocol address with one of the following attributes of the DISPATCHERS parameter:
You want to configure one or more of the optional dispatcher attributes:
A protocol address is required and is specified using one or more of the following attributes:
||Specify the network protocol address of the endpoint on which the dispatchers listen.|
||Specify the network description of the endpoint on which the dispatchers listen, including the network protocol address. The syntax is as follows:
||Specify the network protocol for which the dispatcher generates a listening endpoint. For example:
See the Oracle Database Net Services Reference for further information about protocol address syntax.
The following attribute specifies how many dispatchers this configuration should have. It is optional and defaults to 1.
The following attributes tell the instance about the network attributes of each dispatcher of this configuration. They are all optional.
||Specify the maximum number of network connections to allow for each dispatcher.|
||Specify the maximum number of network sessions to allow for each dispatcher.|
||Specify the duration of a TICK in seconds. A TICK is a unit of time in terms of which the connection pool timeout can be specified. Used for connection pooling.|
||Specify an alias name for the listeners with which the PMON process registers dispatcher information. Set the alias to a name that is resolved through a naming method.|
||Used to enable the Oracle Connection Manager session multiplexing feature.|
||Used to enable connection pooling.|
||Specify the service names the dispatchers register with the listeners.|
You can specify either an entire attribute name a substring consisting of at least the first three characters. For example, you can specify
SESSI=3, and so forth.
See Also:Oracle Database Reference for more detailed descriptions of the attributes of the
Once you know the number of possible connections for each process for the operating system, calculate the initial number of dispatchers to create during instance startup, for each network protocol, using the following formula:
Number of dispatchers = CEIL ( max. concurrent sessions / connections for each dispatcher )
CEIL returns the result roundest up to the next whole integer.
For example, assume a system that can support 970 connections for each process, and that has:
A maximum of 4000 sessions concurrently connected through TCP/IP and
A maximum of 2,500 sessions concurrently connected through TCP/IP with SSL
DISPATCHERS attribute for TCP/IP should be set to a minimum of five dispatchers (4000 / 970), and for TCP/IP with SSL three dispatchers (2500 / 970:
Depending on performance, you may need to adjust the number of dispatchers.
You can specify multiple dispatcher configurations by setting
DISPATCHERS to a comma separated list of strings, or by specifying multiple
DISPATCHERS parameters in the initialization file. If you specify
DISPATCHERS multiple times, the lines must be adjacent to each other in the initialization parameter file. Internally, Oracle Database assigns an
INDEX value (beginning with zero) to each
DISPATCHERS parameter. You can later refer to that
DISPATCHERS parameter in an
ALTER SYSTEM statement by its index number.
Some examples of setting the
DISPATCHERS initialization parameter follow.
Example: Forcing the IP Address Used for Dispatchers The following hypothetical example will create two dispatchers that will listen on the specified IP address. The address must be a valid IP address for the host that the instance is on. (The host may be configured with multiple IP addresses.)
You can control the number of dispatcher processes in the instance. Unlike the number of shared servers, the number of dispatchers does not change automatically. You change the number of dispatchers explicitly with the
ALTER SYSTEM statement. In this release of Oracle Database, you can increase the number of dispatchers to more than the limit specified by the
MAX_DISPATCHERS parameter. It is planned that
MAX_DISPATCHERS will be taken into consideration in a future release.
Monitor the following views to determine the load on the dispatcher processes:
See Also:Oracle Database Performance Tuning Guide for information about monitoring these views to determine dispatcher load and performance
If these views indicate that the load on the dispatcher processes is consistently high, then performance may be improved by starting additional dispatcher processes to route user requests. In contrast, if the load on dispatchers is consistently low, reducing the number of dispatchers may improve performance.
To dynamically alter the number of dispatchers when the instance is running, use the
ALTER SYSTEM statement to modify the
DISPATCHERS attribute setting for an existing dispatcher configuration. You can also add new dispatcher configurations to start dispatchers with different network attributes.
When you reduce the number of dispatchers for a particular dispatcher configuration, the dispatchers are not immediately removed. Rather, as users disconnect, Oracle Database terminates dispatchers down to the limit you specify in
For example, suppose the instance was started with this
DISPATCHERS setting in the initialization parameter file:
To increase the number of dispatchers for the TCP/IP protocol from 2 to 3, and decrease the number of dispatchers for the TCP/IP with SSL protocol from 2 to 1, you can issue the following statement:
ALTER SYSTEM SET DISPATCHERS = '(INDEX=0)(DISP=3)', '(INDEX=1)(DISP=1)';
ALTER SYSTEM SET DISPATCHERS = '(PROT=tcp)(DISP=3)', '(PROT=tcps)(DISP=1)';
Note:You need not specify (
DISP=1). It is optional because 1 is the default value for the
If fewer than three dispatcher processes currently exist for TCP/IP, the database creates new ones. If multiple dispatcher processes currently exist for TCP/IP with SSL, then the database terminates the extra ones as the connected users disconnect.
Suppose that instead of changing the number of dispatcher processes for the TCP/IP protocol, you want to add another TCP/IP dispatcher that supports connection pooling. You can do so by entering the following statement:
ALTER SYSTEM SET DISPATCHERS = '(INDEX=2)(PROT=tcp)(POOL=on)';
INDEX attribute is needed to add the new dispatcher configuration. If you omit (
INDEX=2) in the preceding statement, then the TCP/IP dispatcher configuration at INDEX 0 will be changed to support connection pooling, and the number of dispatchers for that configuration will be reduced to 1, which is the default when the number of dispatchers (attribute
DISPATCHERS) is not specified.
INDEX keyword can be used to identify which dispatcher configuration to modify. If you do not specify
INDEX, then the first dispatcher configuration matching the
PROTOCOL specified will be modified. If no match is found among the existing dispatcher configurations, then a new dispatcher will be added.
INDEX value can range from 0 to
n is the current number of dispatcher configurations. If your
ALTER SYSTEM statement specifies an
INDEX value equal to
n is the current number of dispatcher configurations, a new dispatcher configuration will be added.
To see the values of the current dispatcher configurations--that is, the number of dispatchers, whether connection pooling is on, and so forth--query the
V$DISPATCHER_CONFIG dynamic performance view. To see which dispatcher configuration a dispatcher is associated with, query the
CONF_INDX column of the
When you change the
POOL attributes of a dispatcher configuration, the change does not take effect for existing dispatchers but only for new dispatchers. Therefore, in order for the change to be effective for all dispatchers associated with a configuration, you must forcibly terminate existing dispatchers after altering the
DISPATCHERS parameter, and let the database start new ones in their place with the newly specified properties.
SERVICES are not subject to the same constraint. They apply to existing dispatchers associated with the modified configuration. Attribute
SESSIONS applies to existing dispatchers only if its value is reduced. However, if its value is increased, it is applied only to newly started dispatchers.
ALTER SYSTEM statement, you leave it up to the database to determine which dispatchers to shut down to reduce the number of dispatchers. Alternatively, it is possible to shut down specific dispatcher processes. To identify the name of the specific dispatcher process to shut down, use the
V$DISPATCHER dynamic performance view.
SELECT NAME, NETWORK FROM V$DISPATCHER;
Each dispatcher is uniquely identified by a name of the form Dnnn.
To shut down dispatcher
D002, issue the following statement:
ALTER SYSTEM SHUTDOWN IMMEDIATE 'D002';
IMMEDIATE keyword stops the dispatcher from accepting new connections and the database immediately terminates all existing connections through that dispatcher. After all sessions are cleaned up, the dispatcher process shuts down. If
IMMEDIATE were not specified, the dispatcher would wait until all of its users disconnected and all of its connections terminated before shutting down.
You disable shared server by setting
SHARED_SERVERS to 0. You can do this dynamically with the
SYSTEM statement. When you disable shared server, no new clients can connect in shared mode. However, Oracle Database retains some shared servers until all shared server connections are closed. The number of shared servers retained is either the number specified by the preceding setting of
SHARED_SERVERS or the value of the
MAX_SHARED_SERVERS parameter, whichever is smaller. If both
MAX_SHARED_SERVERS are set to 0, then all shared servers will terminate and requests from remaining shared server clients will be queued until the value of
MAX_SHARED_SERVERS is raised again.
To terminate dispatchers once all shared server clients disconnect, enter this statement:
ALTER SYSTEM SET DISPATCHERS = '';
||Provides information on the dispatcher processes, including name, network address, status, various usage statistics, and index number.|
||Provides configuration information about the dispatchers.|
||Provides rate statistics for the dispatcher processes.|
||Contains information on the shared server message queues.|
||Contains information on the shared servers.|
||Contains information about virtual circuits, which are user connections to the database through dispatchers and servers.|
||Contains information for tuning shared server.|
||Contains size information about various system global area (SGA) groups. May be useful when tuning shared server.|
||Contains detailed statistical information about the SGA, useful for tuning.|
||Lists statistics to help tune the reserved pool and space within the shared pool.|
The database server is preconfigured to allow database resident connection pooling. However, you must explicitly enable this feature by starting the connection pool.
This section contains the following topics:
Oracle Database includes a default connection pool called
SYS_DEFAULT_CONNECTION_POOL. By default, this pool is created, but not started. To enable database resident connection pooling, you must explicitly start the connection pool.
Start the database resident connection pool, as described in "Starting the Database Resident Connection Pool".
Route the client connection requests to the connection pool, as described in "Routing Client Connection Requests to the Connection Pool".
To start the connection pool, use the following steps:
Start SQL*Plus and connect to the database as the
Issue the following command:
SQL> EXECUTE DBMS_CONNECTION_POOL.START_POOL();
Once started, the connection pool remains in this state until it is explicitly stopped. The connection pool is automatically restarted when the database instance is restarted if the pool was active at the time of instance shutdown.
In an Oracle Real Application Clusters (Oracle RAC) environment, you can use any instance to manage the connection pool. Any changes you make to the pool configuration are applicable on all Oracle RAC instances.
In the client application, the connect string must specify the connect type as
The following example shows an easy connect string that enables clients to connect to a database resident connection pool:
The following example shows a TNS connect descriptor that enables clients to connect to a database resident connection pool:
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp) (HOST=myhost) (PORT=1521))(CONNECT_DATA=(SERVICE_NAME=sales) (SERVER=POOLED)))
To disable database resident connection pooling, you must explicitly stop the connection pool. Use the following steps:
Start SQL*Plus and connect to the database as the
Issue the following command:
SQL> EXECUTE DBMS_CONNECTION_POOL.STOP_POOL();
See Also:Oracle Database PL/SQL Packages and Types Reference for more information on the
Note:The operation of disabling the database resident connection pool can be completed only when all client requests that have been handed off to a server are completed.
The connection pool is configured using default parameter values. You can use the procedures in the
DBMS_CONNECTION_POOL package to configure the connection pool according to your usage. In an Oracle Real Application Clusters (Oracle RAC) environment, the configuration parameters are applicable to each Oracle RAC instance.
Table 5-2 lists the parameters that you can configure for the connection pool.
The minimum number of pooled servers in the pool. The default value is 4.
The maximum number of pooled servers in the pool. The default value is 40.
The connection pool reserves 5% of the pooled servers for authentication, and at least one pooled server is always reserved for authentication. When setting this parameter, ensure that there are enough pooled servers for both authentication and connections.
The number of pooled servers by which the pool is incremented if servers are unavailable when a client application request is received. The default value is 2.
The number of session cursors to cache in each pooled server session. The default value is 20.
The maximum time, in seconds, the pooled server can stay idle in the pool. After this time, the server is terminated. The default value is 300.
This parameter does not apply if the pool is at
The maximum time of inactivity, in seconds, for a client after it obtains a pooled server from the pool. After obtaining a pooled server from the pool, if the client application does not issue a database call for the time specified by
The number of times a pooled server can be taken and released to the pool. The default value is 500000.
The time, in seconds, to live for a pooled server in the pool. The default value is 86400.
The number of Connection Brokers that are created to handle client requests. The default value is 1.
Creating multiple Connection Broker processes helps distribute the load of client connection requests if there are a large number of client applications.
The maximum number of connections that each Connection Broker can handle.
The default value is 40000. But if the maximum connections allowed by the platform on which the database is installed is lesser than the default value, this value overrides the value set using
Set the per-process file descriptor limit of the operating system sufficiently high so that it supports the number of connections specified by
CONFIGURE_POOL procedure of the
DBMS_CONNECTION_POOL package enables you to configure the connection pool with advanced options. This procedure is usually used when you must modify all the parameters of the connection pool.
ALTER_PARAM procedure of the
DBMS_CONNECTION_POOL package enables you to alter a specific configuration parameter without affecting other parameters.For example, the following command changes the minimum number of pooled servers used:
SQL> EXECUTE DBMS_CONNECTION_POOL.ALTER_PARAM ('','MINSIZE','10');
The following example, changes the maximum number of connections that each connection broker can handle to 50000.
SQL> EXECUTE DBMS_CONNECTION_POOL.ALTER_PARAM ('','MAXCONN_CBROK','50000');
Before you execute this command, ensure that the maximum number of connections allowed by the platform on which your database is installed is not less than the value you set for
For example, in Linux, the following entry in the
/etc/security/limits.conf file indicates that the maximum number of connections allowed for the user
test_user is 30000.
test_user HARD NOFILE 30000
To set the maximum number of connections that each connection broker can allow to 50000, first change the value in the
limits.conf file to a value not less than 50000.
If you have made changes to the connection pool parameters, but you want to revert to the default pool settings, use the
RESTORE_DEFAULT procedure of the
DBMS_CONNECTION_POOL package. The command to restore the connection pool to its default settings is:
SQL> EXECUTE DBMS_CONNECTION_POOL.RESTORE_DEFAULTS();
See Also:Oracle Database PL/SQL Packages and Types Reference for more information on the
Table 5-3 lists the data dictionary views that provide information about database resident connection pooling. Use these views to obtain information about your connection pool and to monitor the performance of database resident connection pooling.
Contains information about the connection pool such as the pool status, the maximum and minimum number of connections, and timeout for idle sessions.
Contains information about each connection to the connection broker.
Contains pool statistics such as the number of session requests, number of times a session that matches the request was found in the pool, and total wait time for a session request.
Contains connection class level statistics for the pool.
See Also:Oracle Database Reference for more information about these views.
To maximize performance and accommodate many users, a multiprocess Oracle Database system uses background processes. Background processes consolidate functions that would otherwise be handled by multiple database programs running for each user process. Background processes asynchronously perform I/O and monitor other Oracle Database processes to provide increased parallelism for better performance and reliability.
Table 5-4 describes the fundamental background processes, many of which are discussed in more detail elsewhere in this book. The use of additional database features or options can cause more background processes to be present. For example:
When you use Oracle Streams Advanced Queuing, the queue monitor (QMNn) background process is present.
When you specify the
FILE_MAPPING initialization parameter for mapping data files to physical devices on a storage subsystem, then the FMON process is present.
If you use Oracle Automatic Storage Management (Oracle ASM), then additional Oracle ASM–specific background processes are present.
The database writer writes modified blocks from the database buffer cache to the data files. Oracle Database allows a maximum of 36 database writer processes (DBW0-DBW9 and DBWa-DBWj). The
For more information about setting the
The log writer process writes redo log entries to disk. Redo log entries are generated in the redo log buffer of the system global area (SGA). LGWR writes the redo log entries sequentially into a redo log file. If the database has a multiplexed redo log, then LGWR writes the redo log entries to a group of redo log files. See Chapter 12, "Managing the Redo Log" for information about the log writer process.
At specific times, all modified database buffers in the system global area are written to the data files by DBWn. This event is called a checkpoint. The checkpoint process is responsible for signalling DBWn at checkpoints and updating all the data files and control files of the database to indicate the most recent checkpoint.
The system monitor performs recovery when a failed instance starts up again. In an Oracle Real Application Clusters database, the SMON process of one instance can perform instance recovery for other instances that have failed. SMON also cleans up temporary segments that are no longer in use and recovers terminated transactions skipped during system failure and instance recovery because of file-read or offline errors. These transactions are eventually recovered by SMON when the tablespace or file is brought back online.
The process monitor performs process recovery when a user process fails. PMON is responsible for cleaning up the cache and freeing resources that the process was using. PMON also checks on the dispatcher processes (described later in this table) and server processes and restarts them if they have failed.
One or more archiver processes copy the redo log files to archival storage when they are full or a log switch occurs. Archiver processes are the subject of Chapter 13, "Managing Archived Redo Logs".
The recoverer process is used to resolve distributed transactions that are pending because of a network or system failure in a distributed database. At timed intervals, the local RECO attempts to connect to remote databases and automatically complete the commit or rollback of the local portion of any pending distributed transactions. For information about this process and how to start it, see Chapter 35, "Managing Distributed Transactions".
Dispatchers are optional background processes, present only when the shared server configuration is used. Shared server was discussed previously in "Configuring Oracle Database for Shared Server".
See Also:Oracle Database Reference for a complete list of Oracle Database background processes
Note:The parallel execution feature described in this section is available with the Oracle Database Enterprise Edition.
This section describes how to manage parallel processing of SQL statements. In this configuration Oracle Database can divide the work of processing an SQL statement among multiple parallel processes.
The execution of many SQL statements can be parallelized. The degree of parallelism is the number of parallel execution servers that can be associated with a single operation. The degree of parallelism is determined by any of the following:
PARALLEL clause in a statement
For objects referred to in a query, the
PARALLEL clause that was used when the object was created or altered
A default determined by the database
An example of using parallel SQL execution is contained in "Parallelizing Table Creation".
The following topics are contained in this section:
Oracle Database Performance Tuning Guide for information about using parallel hints
When an instance starts up, Oracle Database creates a pool of parallel execution servers which are available for any parallel operation. A process called the parallel execution coordinator dispatches the execution of a pool of parallel execution servers and coordinates the sending of results from all of these parallel execution servers back to the user.
The parallel execution servers are enabled by default, because by default the value for
PARALLEL_MAX_SERVERS initialization parameter is set >0. The processes are available for use by the various Oracle Database features that are capable of exploiting parallelism. Related initialization parameters are tuned by the database for the majority of users, but you can alter them as needed to suit your environment. For ease of tuning, some parameters can be altered dynamically.
Parallelism can be used by several features, including transaction recovery, replication, and SQL execution. In the case of parallel SQL execution, the topic discussed in this book, parallel server processes remain associated with a statement throughout its execution phase. When the statement is completely processed, these processes become available to process other statements.
See Also:Oracle Database VLDB and Partitioning Guide for more information about using parallel execution
You control parallel SQL execution for a session using the
ALTER SESSION statement.
You disable parallel SQL execution with an
ALTER SESSION DISABLE PARALLEL DML|DDL|QUERY statement. All subsequent DML (
DELETE), DDL (
ALTER), or query (
SELECT) operations are executed serially after such a statement is issued. They will be executed serially regardless of any parallel attribute associated with the table or indexes involved. However, statements with a
PARALLEL hint override the session settings.
The following statement disables parallel DDL operations:
ALTER SESSION DISABLE PARALLEL DDL;
You enable parallel SQL execution with an
ALTER SESSION ENABLE PARALLEL DML|DDL|QUERY statement. Subsequently, when a
PARALLEL clause or parallel hint is associated with a statement, those DML, DDL, or query statements will execute in parallel. By default, parallel execution is enabled for DDL and query statements.
A DML statement can be parallelized only if you specifically issue an
ALTER SESSION statement to enable parallel DML:
ALTER SESSION ENABLE PARALLEL DML;
You can force parallel execution of all subsequent DML, DDL, or query statements for which parallelization is possible with the
ALTER SESSION FORCE PARALLEL DML|DDL|QUERY statement. Additionally you can force a specific degree of parallelism to be in effect, overriding any
PARALLEL clause associated with subsequent statements. If you do not specify a degree of parallelism in this statement, the default degree of parallelism is used. Forcing parallel execution overrides any parallel hints in SQL statements.
The following statement forces parallel execution of subsequent statements and sets the overriding degree of parallelism to 5:
ALTER SESSION FORCE PARALLEL DDL PARALLEL 5;
This section contains:
External procedures are procedures that are written in C, C++, Java, or other language, compiled and stored outside the database, and then called by user sessions. For example, a PL/SQL program unit could call one or more C routines that are required to perform special-purpose processing.
These callable routines are stored in a dynamic link library (DLL), or a libunit in the case of a Java class method, and are registered with the base language. Oracle Database provides a special-purpose interface, the call specification (call spec), that enables users to call external procedures in other languages.
When a user session calls an external procedure, the database starts an external procedure agent on the database host computer. The default name of the agent is
extproc. Each session has its own dedicated agent. When a session terminates, the database terminates its agent.
User applications pass to the external procedure agent the name of the DLL or libunit, the name of the external procedure, and any relevant parameters. The external procedure agent then loads the DLL or libunit, runs the external procedure, and passes back to the application any values returned by the external procedure.
See Also:Oracle Database Advanced Application Developer's Guide for information about external procedures
Enabling external procedure calls may involve the following DBA tasks:
Configuring the listener to start the
By default, the database starts the
extproc process. Under the following circumstances, you must change this default configuration so that the listener starts the
You want to use a multithreaded
The database is running in shared server mode on Windows
AGENT clause in the
LIBRARY specification or an
IN clause in the
FUNCTION specification redirects external procedures to a different
Instructions for changing the default configuration are found in the subsection entitled "Set Up the Environment" in the chapter "Developing Applications with Multiple Programming Languages" in Oracle Database Advanced Application Developer's Guide.
Managing libraries or granting privileges related to managing libraries
The database requires DLLs to be accessed through a schema object called a library. For security purposes, by default, only users with the
DBA role can create and manage libraries. Therefore, you may be asked to:
LIBRARY statement to create the library objects that the developers need.
Grant the following privileges to developers:
Only make an explicit grant of these privileges to trusted users, and never to the
PUBLIC role. If you plan to create PL/SQL interfaces to libraries, then only grant the
EXECUTE privilege to the PL/SQL interface. Do not grant
EXECUTE on the underlying library. You must have the
EXECUTE object privilege on the library to create the PL/SQL interface. However, users have this privilege automatically in their own schemas. Explicit grants of
EXECUTE object privilege on a library are rarely required.
See Also:Oracle Database PL/SQL Language Reference for information about the
Sometimes it is necessary to terminate current user sessions. For example, you might want to perform an administrative operation and need to terminate all non-administrative sessions. This section describes the various aspects of terminating sessions, and contains the following topics:
When a session is terminated, any active transactions of the session are rolled back, and resources held by the session (such as locks and memory areas) are immediately released and available to other sessions.
You terminate a current session using the SQL statement
ALTER SYSTEM KILL SESSION. The following statement terminates the session whose system identifier is 7 and serial number is 15:
ALTER SYSTEM KILL SESSION '7,15';
To identify which session to terminate, specify the session index number and serial number. To identify the system identifier (SID) and serial number of a session, query the
V$SESSION dynamic performance view. For example, the following query identifies all sessions for the user
SELECT SID, SERIAL#, STATUS FROM V$SESSION WHERE USERNAME = 'JWARD'; SID SERIAL# STATUS ----- --------- -------- 7 15 ACTIVE 12 63 INACTIVE
A session is
ACTIVE when it is making a SQL call to Oracle Database. A session is
INACTIVE if it is not making a SQL call to the database.
See Also:Oracle Database Reference for a description of the status values for a session
ORA-00028: your session has been killed
If, after receiving the
ORA-00028 message, a user submits additional statements before reconnecting to the database, Oracle Database returns the following message:
ORA-01012: not logged on
An active session cannot be interrupted when it is performing network I/O or rolling back a transaction. Such a session cannot be terminated until the operation completes. In this case, the session holds all resources until it is terminated. Additionally, the session that issues the
ALTER SYSTEM statement to terminate a session waits up to 60 seconds for the session to be terminated. If the operation that cannot be interrupted continues past one minute, the issuer of the
ALTER SYSTEM statement receives a message indicating that the session has been marked to be terminated. A session marked to be terminated is indicated in
V$SESSION with a status of
KILLED and a server that is something other than
If the session is not making a SQL call to Oracle Database (is
INACTIVE) when it is terminated, the
ORA-00028 message is not returned immediately. The message is not returned until the user subsequently attempts to use the terminated session.
When an inactive session has been terminated, the
STATUS of the session in the
V$SESSION view is
KILLED. The row for the terminated session is removed from
V$SESSION after the user attempts to use the session again and receives the
SELECT SID,SERIAL#,STATUS,SERVER FROM V$SESSION WHERE USERNAME = 'JWARD'; SID SERIAL# STATUS SERVER ----- -------- --------- --------- 7 15 INACTIVE DEDICATED 12 63 INACTIVE DEDICATED 2 rows selected. ALTER SYSTEM KILL SESSION '7,15'; Statement processed. SELECT SID, SERIAL#, STATUS, SERVER FROM V$SESSION WHERE USERNAME = 'JWARD'; SID SERIAL# STATUS SERVER ----- -------- --------- --------- 7 15 KILLED PSEUDO 12 63 INACTIVE DEDICATED 2 rows selected.
The following are the data dictionary views that can help you manage processes and sessions.
||Contains information about the currently active processes|
||Lists session information for each current session|
||Contains I/O statistics for each user session|
||Displays the status of various operations that run for longer than 6 seconds (in absolute time). These operations currently include many backup and recovery functions, statistics gathering, and query execution. More operations are added for every Oracle Database release.|
||Displays the current or last wait for each session|
||Lists the last ten wait events for each active session|
||Displays information about blocked sessions|
||Contains session statistics|
||Provides information about current and maximum global resource utilization for some system resources|
||Contains statistics about shared SQL areas. Contains one row for each SQL string. Provides statistics about SQL statements that are in memory, parsed, and ready for execution|