S kip Headers

Oracle® Database Administrator's Guide
10g Release 1 (10.1)
Part Number B10739-01
Go to Table of Contents
Contents
Go to Docum
entation Home
Home
Go to Book List
Book List
Go to Index
Index
Go to Master Index
Master&nb sp;Index
Go to Feedback page
Feedback

Go to previous page
Previous
Go to next page
Next
View PDF

4 Managing Oracle Database Processes

This chapter describes how to manage and monitor th e processes of an Oracle Database instance and contains the following topics:

About Dedicated and Sh ared Server Processes

Oracle Database creates server processes to handle the requests of user processes connected to a n instance. A server process can be either of the following:

Your database is always enabled to allow dedicated server processes, but you must specifically co nfigure and enable shared server by setting one or more initialization parameters.

Dedicated Server Processes

< p>Figure 4-1, "Oracle Database Dedi cated 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 an d use a shared server process. This is illustrated in Figure 4-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 proc ess:

  • To submit a batch job (for example, when a job can allow little or no idle time for the server proc ess)

  • To use Recovery Manager (RMAN) to back up, restore, or recover a database

To reque st a dedicated server connection when Oracle Database is configured for shared server, users must connect using a net service name th at 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 Net Servic es Administrator's Guide for more information about requesting a dedicated server connection

Figure 4-1 Oracle Database Dedicated Server Processes

Description of admin013.gif follows
Description of the illustration admin013.gif

Shared Server Processes

Consider an orde r entry system with dedicated server processes. A customer phones the order desk and places an order, and the clerk taking the call e nters the order into the database. For most of the transaction, the clerk is on the telephone talking to the customer. A server proce ss 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 elimina tes the need for a dedicated server process for each connection (see Figure 4-2).

F igure 4-2 Oracle Database Shared Server Processes

Description of admin011.gif
 follows
Description of the illustration admin011.gif

In a shared server configuration, client user processes connect to a dispatcher. The dis patcher 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 increa sed 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 res ources.

Shared server architecture requires Oracle Net Services. User processes targeting the shared server must connect throu gh Oracle Net Services, even if they are on the same machine as the Oracle Database instance.


See Also:

Oracle Net Services Administrator's Guide for more detailed information about shar ed server, including features such as connection pooling and session multiplexing

Configuring Oracle Database for Shared Server

Shared memory resources are preconfigured to allow the enabling of shared server at run time. You need not configure it by specifying parameters in your initialization parameter file, but you can do so if that better suits your environment. You can start dispatchers and shared server processes (shared servers) dynam ically using the ALTER SYSTEM statement.

This section discusses how to enable shared server and how to set or alt er shared server initialization parameters. It contains the following topics:

Initialization Parameters for Shared Server

The following initialization parameters control shared server operatio n:

  • 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.

  • MA X_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: Configu res 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 se ssions.


See Also:

Oracle Database Reference for more information about these initialization parameters

Enabling Shared Server

Shared server is enabled by set ting the SHARED_SERVERS initialization parameter to a value greater than 0. The other shared server initialization param eters 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 enabl ed at database startup.


Note:

For backward compatibility, if SHARED_SERVERS is not included in the initialization parameter file at database star tup, but DISPATCHERS is included and it specifies at least one dispatcher, shared server is enabled. In this case, the d efault for SHARED_SERVERS is 1.

However, if neither SHARED_SERVERS nor DISPATCHERS is incl uded in the initialization file, you cannot start shared server after the instance is brought up by just altering the DISPATCHE RS parameter. You must specifically alter SHARED_SERVERS to a nonzero value to start shared server.


Determining a Value for SHARED_SERVERS

The SHARED_SERVERS initialization parameter specifies the minimum number of shared servers that you want created when the instance is started. Aft er instance startup, Oracle Database can dynamically adjust the number of shared servers based on how busy existing shared servers ar e and the length of the request queue.

In typical systems, the number of shared servers stabilizes at a ratio of one shared se rver 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 ser ver usage-to-request ratio is high, the connections-to-server ratio could be lower.

The PMON (process monitor) background proc ess cannot terminate shared servers below the value specified by SHARED_SERVERS. Therefore, you can use this parameter t o 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 telemarket ing center staffed by 1000 agents. On average, each agent spends 90% of the time talking to customers and only 10% of the time lookin g up and updating records. To keep the shared servers from being terminated as agents talk to customers and then spawned again as age nts access the database, a DBA specifies that the optimal number of shared servers is 100.

However, not all work shifts are st affed 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.

Decreasing the Number of Shared Server Processes

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 sha red servers is decreased to the value of the SHARED_SERVERS parameter, any shared servers that become inactive are marke d by PMON for termination.

The following statement reduces the number of shared servers:

ALTER S
YSTEM SET SHARED_SERVERS = 5;

Setting SHARED_SERVERS to 0 disables sh ared server. For more information, please refer to "Disabling Shared Servers".

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_SE RVERS value by setting SHARED_SERVERS to a value higher than MAX_SHARED_SERVERS. You can subsequentl y place a new upper limit on the number of shared servers by dynamically altering the MAX_SHARED_SERVERS to a value high er than SHARED_SERVERS.

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:

Th e 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 acc ess the database at the same time, batch jobs can connect to dedicated servers without having to wait for the shared servers to be br ought down after processing agents' requests.

Another reason to limit the number of shared servers is to prevent the concurren t run of too many server processes from slowing down the system due to heavy swapping, although PROCESSES can serve as t he upper bound for this rather than MAX_SHARED_SERVERS.

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 supp ort 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.

Limiting the Number of Shared Server Sessions

The SHARED_SE RVER_SESSIONS initialization parameter specifies the maximum number of concurrent shared server user sessions. Setting this pa rameter, which is a dynamic parameter, lets you reserve database sessions for dedicated servers. This in turn ensures that administra tive 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.

Protecting Shared Memory

The CIRCU ITS 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 initializa tion parameter and system resources.

Confi guring Dispatchers

The DISPATCHERS initialization parameter config ures 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 defa ult Oracle Database creates one dispatcher for the TCP protocol. The equivalent DISPATCHERS explicit setting of the init ialization parameter for this configuration is:

dispatchers="(PROTOCOL=tcp)"

You can config ure more dispatchers, using the DISPATCHERS initialization parameter, if either of the following conditions apply:

< ul>
  • You need to configure a protocol other than TCP/IP. You configure a protocol address with one of the followin g attributes of the DISPATCHERS parameter:

  • You want to configure one or more of the optional dispatcher attributes:

  • DISPATCHERS Initializat ion Parameter Attributes

    This section provides brief descriptions of the attributes that can be specified with the DISPATCHERS initialization parameter.

    A protocol address is required and is s pecified using one or more of the following attributes:

    Attribute Description
    ADDRESS Specify the network protocol address of the endpoint on which the dispatchers listen.
    DESCRIPTION Specify the network description of the endpoint on which the dispatchers listen, including the network p rotocol address. The syntax is as follows:
    (DESCRIPTION=(ADDRESS=...))
    
    PROTOCOL Specify the network protocol for which the dispatcher generates a listening endpoint. For example :
    (PROTOCOL=tcp) 
    

    See the Oracle Net Services Reference Guide for further information about protocol address syntax.


    The following attribute specifies how many dispatchers this configur ation should have. It is optional and defaults to 1.

    Attribute Description
    DISPATCHERS Specify the initial number of dispatchers to start.

    The following attributes tell the instance about the network attributes of each dispatcher of this con figuration. They are all optional.

    Attribute Description
    CONNECTIONS Specify the maximum number of network connections to allow for each dispatcher.
    SESSIONS Specify the maximum number of network sessions to allow for each dispatcher.
    TICKS Specify the duration of a TICK in seconds. A TICK is a unit of time in terms of which the con nection pool timeout can be specified. Used for connection pooling.
    LISTENER 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.
    MULTIPLEX Used to enable the Oracle Co nnection Manager session multiplexing feature.
    POOL Used to enable connecti on pooling.
    SERVICE Specify the service names the dispatchers register with the listeners.

    You can specify either an entire attribute n ame a substring consisting of at least the first three characters. For example, you can specify SESSIONS=3, SES=3< /code>, SESS=3, or SESSI=3, and so forth.


    See Also:

    Oracle Database Reference for more detailed descriptions of the attributes of the DISPATCHERS initialization parameter
    < a id="sthref575" name="sthref575">

    Setting the Initial Number of D ispatchers

    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.

    Som e examples of setting the DISPATCHERS initialization parameter follow.


    Example: Typical

    This is a typical example of setting the DISPATCHERS initializatio n parameter.

    DISPATCHERS="(PROTOCOL=TCP)(DISPATCHERS=2)"
    

    Example: Forcing the IP Address Used for Dispatchers

    The following hypothetical example w ill 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.)

    DISPATCHERS="(ADDRESS=(PROTOC
    OL=TCP)(HOST=144.25.16.201))(DISPATCHERS=2)"
    

    Example: Forcing the Po rt Used by Dispatchers

    To force the dispatchers to use a specific port as the listening endpoint, add the PORT attribute as follows:

    DISPATCHERS="(ADDRESS=(PROTOCOL=TCP)(PORT=5000))"
    DISPATCHERS="(A
    DDRESS=(PROTOCOL=TCP)(PORT=5001))"
    

    Altering the Number of Dispatcher s

    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 stat ement. In this release of Oracle Database, you can increase the number of dispatchers to more than the limit specified by the M AX_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:

    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, redu cing the number of dispatchers may improve performance.

    To dynamically alter the number of dispatchers when the instance is ru nning, use the ALTER SYSTEM statement to modify the DISPATCHERS attribute setting for an existing dispatche r configuration. You can also add new dispatcher configurations to start dispatchers with different network attributes.

    When y ou reduce the number of dispatchers for a particular dispatcher configuration, the dispatchers are not immediately removed. Rather, a s users disconnect, Oracle Database terminates dispatchers down to the limit you specify in DISPATCHERS,

    For exam ple, suppose the instance was started with this DISPATCHERS setting in the initialization parameter file:

    DISPATCHERS='(PROT=tcp)(DISP=2)', '(PROT=tcps)(DISP=2)'
    
    

    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 foll owing statement:

    ALTER SYSTEM SET DISPATCHERS = '(INDEX=0)(DISP=3)', '(INDEX=1)(DISP=1)';
    
    

    o r

    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 DISPATCHERS parameter.

    If fewer than three dispatcher processes currently exist for TCP/IP, the database creates new on es. If more than one dispatcher process currently exists for TCP/IP with SSL, then the database terminates the extra ones as the conn ected 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)';
    
    

    The INDEX attribute is needed to add the new dispatcher configuration. If you omit (INDEX=2) in the preceding statement, then the TCP/IP dispatcher co nfiguration at INDEX 0 will be changed to support connection pooling, and the number of dispatchers for that configuration will be re duced to 1, which is the default when the number of dispatchers (attribute DISPATCHERS) is not specified.

    Notes on Altering Dis patchers
    • The INDEX keyword can be used to identify which dispatcher configuration t o modify. If you do not specify INDEX, then the first dispatcher configuration matching the DESCRIPTION, ADDRESS, or PROTOCOL specified will be modified. If no match is found among the existing dispatcher configura tions, then a new dispatcher will be added.

    • The INDEX value can range from 0 to n -1, where n is the current number of dispatcher configurations. If your ALTER SYSTEM s tatement specifies an INDEX value equal to n, where n is the current number of dispatcher configurations, a new dispatcher configuration will be added.

    • To see the values of the cur rent 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 V$DISPATCHER view.

    • When you change the DESCRIPTI ON, ADDRESS, PROTOCOL, CONNECTIONS, TICKS, MULTIPLEX, and POOL attributes of a dispatcher configuration, the change does not take effect for existing dispatchers but only for new di spatchers. Therefore, in order for the change to be effective for all dispatchers associated with a configuration, you must forcibly kill existing dispatchers after altering the DISPATCHERS parameter, and let the database start new ones in their place w ith the newly specified properties.

      The attributes LISTENER and SERVICES are not subject to the same constraint. They apply to existing dispatchers associated with the modified configuration. Attribute SESSIONS applies t o existing dispatchers only if its value is reduced. However, if its value is increased, it is applied only to newly started dispatch ers.

    Disab ling Shared Servers

    You disable shared server by setting SHARED_SERVERS to 0. No new client can connect in shared mode. However, when you set SHARED_SERVERS to 0, Oracle Database retains some shared servers until all shared server connections are closed. The number of shared servers retained is either the number speci fied by the preceding setting of SHARED_SERVERS or the value of the MAX_SHARED_SERVERS parameter, whichever is smaller. If both SHARED_SERVERS and MAX_SHARED_SERVERS are set to 0, then all shared servers will termi nate and requests from remaining shared server clients will be queued until the value of SHARED_SERVERS or MAX_SHA RED_SERVERS is raised again.

    To terminate dispatchers once all shared server clients disconnect, enter this statement:< /p>

    ALTER SYSTEM SET DISPATCHERS = '';
    
    < a id="i1009696" name="i1009696">

    Monitoring Shared Server

    The following views are use ful for obtaining information about your shared server configuration and for monitoring performance.

    View Description
    V$DISPATCHER Provides information on the dispatcher processes, including name, network addr ess, status, various usage statistics, and index number.
    V$DISPATCHER_CONFIG Provides configuration information about the dispatchers.
    V$DISPATCHER_ RATE Provides rate statistics for the dispatcher processes.
    V$QUEUE Contains information on the shared server message queues.
    V$SHARED_SERVER Contains information on t he shared servers.
    V$CIRCUIT< /td> Contains information about virtual circuits, which are user connections to the data base through dispatchers and servers.
    V$SHARED_SERVER_MONITOR Contains information for tuning shared server.
    V$SGA Contains size information about various system global area (SGA) groups. May be useful when tuning shared ser ver.
    V$SGASTAT Contains detailed statistical information about the SGA, useful for tuning.
    V$SHARED_POOL_RESERVED Lists statistics to help tune the reserved pool and space within the shared pool.


    < strong>See Also:


    About Oracle Database Background Processes

    To maximize performance and accommodate many users, a multiprocess Oracle Database system uses background processes. Background processes consolidate functions t hat would otherwise be handled by multiple database programs running for each user process. Background processes asynchronously perfo rm I/O and monitor other Oracle Database processes to provide increased parallelism for better performance and reliability.

    Table 4-1 describes the basic Oracle Database background processes, many of which are discussed in more detail elsewhere in this book. The use of additional database server features or options can cause more background processes to be present. For example, when you use Advanced Queuing, the queue monitor (QMNn) background process is present. When you specify the FILE_MAPPING initialization parameter for mapping datafiles to physical devices on a storage subsystem, then the FMON proce ss is present.

    Table 4-1 Oracle Database Background Processes

    < /table>

    Process Name Description
    Database writer (DBWn) The database writer write s modified blocks from the database buffer cache to the datafiles. Oracle Database allows a maximum of 20 database writer processes ( DBW0-DBW9 and DBWa-DBWj). The initialization parameter DB_WRITER_PROCESSES specifies the number of DBWn process es. The database selects an appropriate default setting for this initialization parameter (or might adjust a user specified setting) based upon the number of CPUs and the number of processor groups.

    For more information about setting the DB_WRITER_PROCESSE S initialization parameter, see the Oracle Database Performance Tuning Guide.

    Log writer (LGWR) The log writer process writes redo log entries to disk. Redo log entries are generated in the redo log buf fer of the system global area (SGA), and LGWR writes the redo log entries sequentially into a redo log file. If the database has a mu ltiplexed redo log, LGWR writes the redo log entries to a group of redo log files. See Chapter 6, " Managing the Redo Log" for information about the log writer process.
    Checkpoint (CKPT) At specific times, all modified database buffers in the system global area are written t o the datafiles by DBWn. This event is called a checkpoint. The checkpoint process is responsible for signalling DBWn at checkpoints and updating all the datafiles and control files of the database to indicate the most recent checkpoint.
    System monitor (SMON) The system monitor performs recover y when a failed instance starts up again. In a Real Application Clusters database, the SMON process of one instance can perform insta nce recovery for other instances that have failed. SMON also cleans up temporary segments that are no longer in use and recovers dead transactions skipped during system failure and instance recovery because of file-read or offline errors. These transactions are even tually recovered by SMON when the tablespace or file is brought back online.

    SMON also coalesces free extents within the database dictionary-managed tablespaces to make free space contiguous and easier to allocate. See "Coalescing Free Space in Dictionary-Managed Tablespaces").

    Process monitor (PMON) The process monitor performs process recovery when a user process fails. PMON is responsible for clea ning 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.
    Archiver (ARCn)< /td> One or more archiver processes copy the redo log files to archival storage when the y are full or a log switch occurs. Archiver processes are the subject of Chapter 7, " Managing Archiv ed Redo Logs".
    Recoverer (RECO) The recover er process is used to resolve distributed transactions that are pending due to 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 33, " Managing Distributed Transactions".
    Dispatcher (Dnnn) Dispatchers are optional background processes, present only when the shared server c onfiguration is used. Shared server was discussed previously in "Configuring Oracle Database for Shared Server".
    Global Cache Service (LMS) In an Oracle R eal Application Clusters environment, this process manages resources and provides inter-instance resource control.

    See Also:

    Oracle Da tabase Concepts for more information about Oracle Database background processes

    Managing Processes for Parallel SQL Executi on


    Note:

    The parallel execution feature described in this section is available with the Oracle Database Enterpr ise Edition.

    This section describes how to manage paralle l processing of SQL statements. In this configuration Oracle Database can divide the work of processing an SQL statement among multip le 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:

    An example of using parallel SQL execution is cont ained in "Parallelizing Table Creation".

    The following topics are contained in this section:

    Altering Parallel Execution for a Session

    You control parallel SQL execution for a session using the ALTER SESSION statement.

    Disabling Parallel SQL Execution

    You disable parallel SQL executio n with an ALTER SESSION DISABLE PARALLEL DML|DDL|QUERY statement. All subsequent DML (INSERT, UPDATE< /code>, DELETE), DDL (CREATE, ALTER), or query (SELECT) operations are executed s erially after such a statement is issued. They will be executed serially regardless of any PARALLEL clause associated wi th the statement or parallel attribute associated with the table or indexes involved.

    The following statement disables paralle l DDL operations:

    ALTER SESSION DISABLE PARALLEL DDL;
    

    Enabling Parallel SQL Execution

    You enable parallel SQL execution with an ALTER SESSION ENABLE P ARALLEL DML|DDL|QUERY statement. Subsequently, when a PARALLEL clause or parallel hint is associated with a state ment, those DML, DDL, or query statements will execute in parallel. By default, parallel execution is enabled for DDL and query state ments.

    A DML statement can be parallelized only if you specifically issue an ALTER SESSION statement to enable pa rallel DML:

    ALTER SESSION ENABLE PARALLEL DML;
    

    Forcing Parallel SQL Execution

    You can force parallel execution of all subsequent DML, DDL, or query statements for which parallelization is possibl e with the ALTER SESSION FORCE PARALLEL DML|DDL|QUERY statement. Additionally you can force a specific degree of paralle lism to be in effect, overriding any PARALLEL clause associated with subsequent statements. If you do not specify a degr ee of parallelism in this statement, the default degree of parallelism is used. However, a degree of parallelism specified in a state ment through a hint will override the degree being forced.

    The following statement forces parallel execution of subsequent sta tements and sets the overriding degree of parallelism to 5:

    ALTER SESSION FORCE PARALLEL DDL PARALLEL 5
    ;
    
    < /a>

    Managing Processes for External Procedures

    < a id="sthref626" name="sthref626">External procedures are procedures written in one language that are called from another program in a different language. An example is a PL/SQL program calling 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 metho d, 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 from other languages.

    To call an external procedure, an app lication alerts a network listener process, which in turn starts an external procedure agent. The default name of the agent is extproc, and this agent must reside on the same computer as the database server. Using the network connection established by t he listener, the application passes to the external procedure agent the name of the DLL or libunit, the name of the external procedur e, and any relevant parameters. The external procedure agent then loads, DLL or libunit, runs the external procedure, and passes back to the application any values returned by the external procedure.

    To control access to DLLs, the database administrator grant s execute privileges on the appropriate DLLs to application developers. The application developers write the external procedures and grant execute privilege on specific external procedures to other users.


    Note:

    The external library (DLL file) must be statically linked. In other words, it mu st not reference any external symbols from other external libraries (DLL files). Oracle Database does not resolve such symbols, so th ey can cause your external procedure to fail.

    The environ ment for calling external procedures, consisting of tnsnames.ora and listener.ora entries, is configured by default during the installation of your database. You may need to perform additional network configuration steps for a higher level of security. These steps are documented in the Oracle Net Servi ces Administrator's Guide.


    See Also:

    Oracle Database Appl ication Developer's Guide - Fundamentals for information about external procedures

    Terminating Sessions

    Sometimes it is necessary to terminate current user sessions. For example, you might want to perfo rm an administrative operation and need to terminate all nonadministrative sessions. This section describes the various aspects of te rminating sessions, and contains the following topics:

    When a session is terminated, any active transactions of the sessio n 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 state ment terminates the session whose system identifier is 7 and serial number is 15:

    ALTER SYSTEM KILL SES
    SION '7,15';
    

    Identifying Which Session to Terminate

    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 id entifies all sessions for the user jward:

    SELECT SID, SERIAL#, STATUS
      FROM V$SESSION
      W
    HERE USERNAME = 'JWARD';
    
    SID    SERIAL#    STATUS
    -----  ---------  --------
        7         15  ACTIVE 
       12         63  INACTIVE
    
    <
    /pre>
    
    

    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 Da tabase Reference for a description of the status values for a session

    Terminating an Active Session

    If a user session is pro cessing a transaction (ACTIVE status) when you terminate the session, the transaction is rolled back and the user immedi ately receives the following message:

    ORA-00028: your session has been killed
    
    

    If, after rec eiving 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 interru pted when it is performing network I/O or rolling back a transaction. Such a session cannot be terminated until the operation complet es. In this case, the session holds all resources until it is terminated. Additionally, the session that issues the ALTER SYSTE M statement to terminate a session waits up to 60 seconds for the session to be terminated. If the operation that cannot be in terrupted continues past one minute, the issuer of the ALTER SYSTEM statement receives a message indicating that the ses sion 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 PSEUDO.

    Terminating an Inactive Session

    < a id="sthref638" name="sthref638">If the session is not making a SQL call to Oracle Database (is INACTIVE) when it i s 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 ORA-00028 message.< /a>

    In the following example, an inactive session is terminated. First, V$SESSION is queried to identify the SID and SERIAL# of the session, and then the session is terminated.

    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 sel
    ected.
    
    ALTER SYSTEM KILL SESSION '7,15';
    Statement processed.
    
    SELECT SID, SERIAL#, STATUS, SERVER
       FROM V$SESSION
       WHERE USERNA
    ME = 'JWARD';
    
    SID    SERIAL#   STATUS     SERVER
    -----  --------  ---------  ---------
        7        15  KILLED     PSEUDO
       12
       63  INACTIVE   DEDICATED
    2 rows selected.
    

    Monitoring the Operation of Your Database

    It is important that you monitor the operation of your database on a regular basis. Doing so not only informs you about erro rs that have not yet come to your attention but also gives you a better understanding of the normal operation of your database. Being familiar with normal behavior in turn helps you recognize when something is wrong.

    This section describes some of the options available to you for monitoring the operation of your database.

    Server-Generated Alerts

    A server-generated alert is a notification from the Oracle Database server of an impending problem. The notification may contain suggestions for correcting the problem. Notifications are also provided when the problem condition has been cleared.

    Alerts are automatically generated when a problem occurs or when data does not ma tch expected values for metrics, such as the following:

    • Physical Reads Per Sec

    • User Commits Per Sec

    • SQL Service Response Time

    Server-generated alerts can be based on threshold levels or can issue simply because an event has occurred. Threshold-based alerts can be triggered at both threshold war ning and critical levels. The value of these levels can be customer-defined or internal values, and some alerts have default threshol d levels which you can change if appropriate. For example, by default a server-generated alert is generated for tablespace space usag e when the percentage of space usage exceeds either the 85% warning or 97% critical threshold level. Examples of alerts not based on threshold levels are:

    • Snapshot Too Old

    • Resumable Session Suspended

    • Recovery Area Space Usage

    An alert message is sent to th e predefined persistent queue ALERT_QUE owned by the user SYS. Oracle Enterprise Manager reads this queue a nd provides notifications about outstanding server alerts, and sometimes suggests actions for correcting the problem. The alerts are displayed on the Enterprise Manager console and can be configured to send email or pager notifications to selected administrators. If an alert cannot be written to the alert queue, a message about the alert is written to the Oracle Database alert log.

    Backgro und processes periodically flush the data to the Automatic Workload Repository to capture a history of metric values. The alert histo ry table and ALERT_QUE are purged automatically by the system at regular intervals.

    The most convenient way to set and view threshold values is to use Enterprise Manager. To manage threshold-based alerts thr ough Enterprise Manager:

    • On the Database Home page, click on the Manage Metrics link at the bottom of the page to display the Thresholds page.

    • On the Thresholds page, you can edit the threshold values.


    < table class="notealso" summary="This is a layout table to format a tip" title="This is a layout table to format a tip" dir="ltr" bord er="1" width="80%" frame="hsides" rules="groups" cellpadding="3" cellspacing="0">

    See Also:

    Oracl e Enterprise Manager Concepts for information about alerts available with Oracle Enterprise Manager

    Using APIs to Administer Server-Generated Alerts

    You can view and change threshold settings for the server alert metrics using the SET_THRESHOLD and GE T_THRESHOLD procedures of the DBMS_SERVER_ALERTS PL/SQL package. The DBMS_AQ and DBMS_AQADM packages provide procedures for accessing and reading alert messages in the alert queue.


    See Also:

    PL/SQL Packages and Types Reference for information about the DBMS_SERVER_ALERTS, DB MS_AQ, and DBMS_AQADM packages

    Setting Threshold Levels

    The following example shows how to set thresholds with the SET_T HRESHOLD procedure for CPU time for each user call for an instance:

    DBMS_SERVER_ALERT.SET_THRESH
    OLD(
     DBMS_SERVER_ALERT.CPU_TIME_PER_CALL, DBMS_SERVER_ALERT.OPERATOR_GE, '8000', 
     DBMS_SERVER_ALERT.OPERATOR_GE, '10000', 1, 2, 'in
    st1',
     DBMS_SERVER_ALERT.OBJECT_TYPE_SERVICE, 'main.regress.rdbms.dev.us.oracle.com');
    
    

    In this example, a warning alert i s issued when CPU time exceeds 8000 microseconds for each user call and a critical alert is issued when CPU time exceeds 10,000 micro seconds for each user call. The arguments include:

    • CPU_TIME_PER_CALL specifies the metric i dentifier. For a list of support metrics, see PL/ SQL Packages and Types Reference.

    • The observation period is set to 1 minute. This period specif ies the number of minutes that the condition must deviate from the threshold value before the alert is issued.

    • The number of consecutive occurrences is set to 2. This number specifies how many times the metric value must violate the thre shold values before the alert is generated.

    • The name of the instance is set to inst1.

    • The constant DBMS_ALERT.OBJECT_TYPE_SERVICE specifies the object type on which the threshold is set. In this example, the service name is main.regress.rdbms.dev.us.oracle.com.

    Retrieving Threshold Information

    To retrieve threshold values, use the GET_THRESH OLD procedure. For example:

    DECLARE
     warning_operator         BINARY_INTEGER;
     warning_value
            VARCHAR2(60);
     critical_operator        BINARY_INTEGER; 
     critical_value           VARCHAR2(60);
     observation_period       BI
    NARY_INTEGER;
     consecutive_occurrences  BINARY_INTEGER;
    BEGIN
     DBMS_SERVER_ALERT.GET_THRESHOLD(
     DBMS_SERVER_ALERT.CPU_TIME_PER_CALL,
     warning_operator, warning_value,
        critical_operator, critical_value, observation_period, 
        consecutive_occurrences, 'inst1',
    DBMS_SERVER_ALERT.OBJECT_TYPE_SERVICE, 'main.regress.rdbms.dev.us.oracle.com');
     DBMS_OUTPUT.PUT_LINE('Warning operator:       ' || w
    arning_operator);
     DBMS_OUTPUT.PUT_LINE('Warning value:          ' || warning_value);
     DBMS_OUTPUT.PUT_LINE('Critical operator:
    ' || critical_operator);
     DBMS_OUTPUT.PUT_LINE('Critical value:         ' || critical_value);     
     DBMS_OUTPUT.PUT_LINE('Observation
    _period:     ' || observation_period);
     DBMS_OUTPUT.PUT_LINE('Consecutive occurrences:' || consecutive_occurrences);
    END;
    / 
    

    You can also check specific threshold settings with the DBA_THRESHOLDS view. For example:

    SELECT metrics_name, warning_value, critical_value, consecutive_occurrences 
       FROM DBA_THRESHOLDS 
       WHERE metrics_name LIKE '%
    CPU Time%';
    
    Additional APIs to Manage Server-Generated Alerts

    If you use your own tool rather than Enterprise Manager to display alerts, you must subscribe to the ALERT_QUE, read the ALERT_QUE, and display an alert notification after setting the threshold levels for an alert. To create an age nt and subscribe the agent to the ALERT_QUE, use the CREATE_AQ_AGENT and ADD_SUBSCRIBER proced ures of the DBMS_AQADM package.

    Next you must associate a database user with the subscribing agent, because only a user associated with the subscribing agent can access queued messages in the secure ALERT_QUE. You must also assign th e enqueue privilege to the user. Use the ENABLE_DB_ACCESS and GRANT_QUEUE_PRIVILEGE procedures of the DBMS_AQADM package.

    Optionally, you can register with the DBMS_AQ.REGISTER procedure to receive an asynch ronous notification when an alert is enqueued to ALERT_QUE. The notification can be in the form of email, HTTP post, or PL/SQL procedure.

    To read an alert message, you can use the DBMS_AQ.DEQUEUE procedure or OCIAQDeq ca ll. After the message has been dequeued, use the DBMS_SERVER_ALERT.EXPAND_MESSAGE procedure to expand the text of the me ssage.

    Viewing Alert Data

    T he following dictionary views provide information about server alerts:

    • DBA_THRESHOLDS lists the threshold settings defined for the instance.

    • DBA_OUTSTANDING_ALERTS describes the outs tanding alerts in the database.

    • DBA_ALERT_HISTORY lists a history of alerts that have been cleared.

    • V$ALERT_TYPES provides information such as group and type for each alert.

    • V$METRICNAME contains the names, identifiers, and other information about the system metrics.

    • V$METRIC and V$METRIC_HISTORY views contain system-level metric values in memory.


    See Also:

    Oracle Database Reference for information on static dat a dictionary views and dynamic performance views

    < !-- class="sect3" -->

    Monitoring the Database Using Trace Files and the Ale rt File

    Each server and background process can write to an associated trace file. When an internal error is detected by a process, it dumps information about the error to its trace file. Some of the information written to a trace file is intended for the database ad ministrator, Other information is for Oracle Support Services. Trace file information is also used to tune applications and instances .

    The alert file, or alert log, is a special trace file. The alert fi le of a database is a chronological log of messages and errors, and includes the following items:

    • All in ternal errors (ORA-600), block corruption errors (ORA-1578), and deadlock errors (ORA-60) that occur

    • Administrative operations, such as CREATE, ALTER, and DROP statements and STARTUP, SHUTDOWN, and ARCHIVELOG statements

    • Mess ages and errors relating to the functions of shared server and dispatcher processes

    • Errors occurring dur ing the automatic refresh of a materialized view

    • The values of all initialization parameters that had no ndefault values at the time the database and instance start

    Oracle Database uses the alert file to record these oper ations as an alternative to displaying the information on an operator's console (although some systems also display information on th e console). If an operation is successful, a "completed" message is written in the alert file, along with a timestamp.

    Initial ization parameters controlling the location and size of trace files are:

    • BACKGROUND_DUMP_DEST

    • USER_DUMP_DEST

    • MAX_DUMP_FILE_SIZE

    These parameters are discussed in the sections that follow.


    See Also:

    Oracle Database Reference for information about initialization parameters that control the writing to trace files

    Using the Trace Files

    Check the alert file and other trace files of an instance periodically to learn whether the background processes have encountered errors. For example, when the log writer process (LGWR) cannot write to a member o f a log group, an error message indicating the nature of the problem is written to the LGWR trace file and the database alert file. S uch an error message means that a media or I/O problem has occurred and should be corrected immediately.

    Oracle Database also writes values of initialization parameters to the alert file, in addition to other important statistics.

    Specif ying the Location of Trace Files

    All trace files for background processes and the alert file are written to the directory specified by the initializat ion parameter BACKGROUND_DUMP_DEST. All trace files for server processes are written to the directory specified by the i nitialization parameter USER_DUMP_DEST. The names of trace files are operating system specific, but each file usually in cludes the name of the process writing the file (such as LGWR and RECO).


    See Also:

    Your operating system specific Oracle documentation for information a bout the names of trace files

    Controlling When Oracle Database Writes to Trace Files

    Background processes always write to a trace file when appropriate. In the case of the ARCn background process, it is possible, through an initialization parameter, to c ontrol the amount and type of trace information that is produced. This behavior is described in "Cont rolling Trace Output Generated by the Archivelog Process". Other background processes do not have this flexibility.

    Trace files are written on behalf of server processes whenever internal errors occur. Additionally, setting the initialization parameter SQL_TRACE = TRUE causes the SQL trace facility to generate performance statistics for the processing of all SQL statements for an instance and write them to the USER_DUMP_DEST directory.

    Optionally, you can request that trace files be generated for server processes. Regardless of the current value of the SQL_TRACE initialization parameter, each session can enable or disable trace logging on behalf of the associated server process by using the SQL statement ALTER SESSION SET SQL _TRACE. This example enables the SQL trace facil ity for a specific session:

    ALTER SESSION SET SQL_TRACE TRUE;
    

    Caution:

    The SQL trace facility for server processes can cause significant system overhead resulting in severe performance impact, so you should enable this feature only when collecting statistic s.

    Use the DBMS_SESSION or the DBMS_MO NITOR package if you want to control SQL tracing for a session.

    R eading the Trace File for Shared Server Sessions

    If shared server is enabled, e ach session using a dispatcher is routed to a shared server process, and trace information is written to the server trace file only i f the session has enabled tracing (or if an error is encountered). Therefore, to track tracing for a specific session that connects u sing a dispatcher, you might have to explore several shared server trace files. To help you, Oracle provides a command line utility p rogram, trcsess, which consolidates all trace information pertaining to a user session in one place and orders the infor mation by time.


    See Also:

    Oracle Database Performance Tuning Guide for information about using the SQL trace facility and using TKPROF and trcsess to interpret the generated trace files

    Monitoring Locks

    Locks are mechanisms that prevent destructive interaction between transactions accessing the same resource. The resources can be either user o bjects, such as tables and rows, or system objects not visible to users, such as shared data structures in memory and data dictionary rows. Oracle Database automatically obtains and manages necessary locks when executing SQL statements, so you need not be concerned with such details. However, the database also lets you lock data manually.

    A deadlock can occur when two or more users are wai ting for data locked by each other. Deadlocks prevent some transactions from continuing to work. Oracle Database automatically detect s deadlock situations and resolves them by rolling back one of the statements involved in the deadlock, thereby releasing one set of the conflicting row locks.

    Oracle Database is designed to avoid deadlocks, and they are not common. Most often they occur when transactions explicitly override the default locking of the database. Deadlocks can affect the performance of your database, so Orac le provides some scripts and views that enable you to monitor locks.

    The utllockt .sql script displays, in a tree fashion, the sessions in the system that are waiting for locks and the locks that they are wai ting for. The location of this script file is operating system dependent.

    A second script, catblock.sql, creates the lock views that utllockt.sql needs, so you must run it before running u tllockt.sql.

    The following views can help you to monitor locks:

    Lists all locks or latches held in the database and all outstanding requests for a lock or latch
    View Description
    V$LOCK Lists the locks currently held by Oracle Database and outstanding requests for a lock or latch
    DBA_BLOCKERS Displays a session if it is holding a lock on an object for which another session is waiting
    DBA_WAITERS Displays a sessio n if it is waiting for a locked object
    DBA_DDL_LOCKS Lists all DDL locks held in the database and all outstandin g requests for a DDL lock
    DBA_DML_LO CKS Lists all DML locks held in the database and all outstanding requests fo r a DML lock
    DBA_LOCK
    DBA_LOCK_INTERNAL Displays a row for each lock or latch that is being held, and one row for each outstand ing request for a lock or latch


    See Also:


    Monitoring Wait Events

    Wait events are statisti cs that are incremented by a server process to indicate that it had to wait for an event to complete before being able to continue pr ocessing. A session could wait for a variety of reasons, including waiting for more input, waiting for the operating system to comple te a service such as a disk write, or it could wait for a lock or latch.

    When a session is waiting for resources, it is not do ing any useful work. A large number of waits is a source of concern. Wait event data reveals various symptoms of problems that might be affecting performance, such as latch contention, buffer contention, and I/O contention.

    Oracle provides several views that display wait event statistics. A discussion of these views and their role in instance tuning is contained in Oracle Database Performance Tuning Guide.

    < !-- class="sect2" -->

    Process and Session Views

    This section lists some of the data dictionary views that you can use to monitor an Oracle Database instance. These views are general in their scope. Other views, more specific to a process, are discussed in the se ction of this book where the process is described.

    View Description
    V$PROCESS Contains information abo ut the currently active processes
    V$ LOCKED_OBJECT Lists all locks acquired by every transaction on the system
    V$SESSION Lists session information for each current session
    V$SESS_IO Contains I/O statistic s for each user session
    V$SESSION_LO NGOPS Displays the status of various operations that run for longer than 6 s econds (in absolute time). These operations currently include many backup and recovery functions, statistics gathering, and query exe cution. More operations are added for every Oracle Database release.
    V$SESSION_WAIT Lists the resources or event s for which active sessions are waiting
    V$SYSSTAT Contains session statistics
    V$RESOURCE_LIMIT Provides information about current and maximum global resource utilization for some system resources
    V$SQLAREA Contains statistics about shared SQL area and contains one row for each SQL string. Also provides statistics about SQL statement s that are in memory, parsed, and ready for execution
    V$LATCH Contains statistics for nonparent latches and su mmary statistics for parent latches




    See Also:

    Oracle Database Reference contains detailed descriptions of these views
    < td align="center" valign="top">Go to next page
    Next
    Go to previous page
    Previous
    Oracle
    Copyright © 2001, 2003 Oracle  ;Corporation
    All Rights Reserved.
    < /tr>
    Go to Documentation Home
    Home
    Go to Book List
    Book List
    
Go to Table of Contents
    Contents
    Go to Index
    Index
    Go to Master Index
    Master Index
    Go to Feedback page
    Feedback