Saturday, January 13, 2018

PMON (Process Monitor)

PMON

The Process Monitor (PMON) monitors other background processes
It is a cleanup type of process that cleans up after failed processes.
Examples include the dropping of a user connection due to a network failure or the abnormal termination (ABEND) of a user application program.
It cleans up the database buffer cache and releases resources that were used by a failed user process.
PMON constantly checks the status of user and database processes. In some cases, failed database processes can be restarted by PMON.
PMON resets the status of the active transaction table, releases locks that are no longer required, and removes the process ID from the list of active processes.
PMON also registers information about the instance and dispatcher processes with the network listener (see "The Oracle Net Listener"). When an instance starts, PMON polls the listener to determine whether it is running. If the listener is running, then PMON passes it relevant parameters. If it is not running, then PMON periodically attempts to contact it.

Like SMON, PMON checks regularly to see whether it is needed; it can be called if another
process detects the need for it.

SMON (System Monitor)

SMON

The System Monitor process (SMON) performs recovery at instance startup if necessary. SMON
is also responsible for cleaning up temporary segments that are no longer in use. If any
terminated transactions were skipped during instance recovery because of file-read or offline
errors, SMON recovers them when the tablespace or file is brought back online.
SMON checks regularly to see whether the process is needed. Other processes can call SMON if
they detect a need for it.
 Instance recovery consists of the following steps:
  1. Rolling forward to recover data that has not been recorded in the data files but that has been recorded in the online redo log. This data has not been written to disk because of the loss of the SGA during instance failure. During this process, SMON reads the redo log files and applies the changes recorded in the redo log to the data blocks. Because all committed transactions have been written to the redo logs, this process completely recovers these transactions. its also perform crash recovery
  2. Opening the database so that users can log on. Any data that is not locked by un recovered transactions is immediately available.
  3. Rolling back uncommitted transactions. They are rolled back by SMON or by the individual server processes as they access locked data.
SMON also performs some space maintenance functions:
  • It combines, or coalesces, adjacent areas of free space in the data files.
  • It deallocates temporary segments to return them as free space in data files. Temporary segments are used to store data during SQL statement processing.
  • In  RAC environment the SMON process of one instance can perform instance recovery for other instances that have failed.
  • SMON wakes up about every 5 minutes to perform housekeeping activities

Oracle Background Process

To maximize the performance and accommodate many users, a multiprocessing oracle system use some additional database process called background process.
The relationship between the physical and memory structures is maintained and enforced by Oracle’s background processes.

Mandatory background process :
  • System monitor (SMON)
  • Process monitor (PMON)
  • Database writer (DBWR)
  • Log writer (LGWR)
  • Checkpoint (CKPT)
Optional process:
  • Archival  (ARCn)

Gather stats in Oracle - most commonly used DBMS_STATS.GATHER_TABLE_STATS parameters

Below is a comprehensive explanation of the most commonly used DBMS_STATS.GATHER_TABLE_STATS parameters and when you should use them. Synta...