Академический Документы
Профессиональный Документы
Культура Документы
Lecture 5
Datafiles
Every database has one or more physical datafiles. The datafiles contain all
the database data. The data of logical database structures, such as tables
and indexes, is physically stored in the datafiles allocated for a database.
The characteristics of datafiles are:
A datafile can be associated with only one database.
Datafiles can have certain characteristics set to let them automatically
extend when the database runs out of space.
One or more datafiles form a logical unit of database storage called a
tablespace.
A database has a set of two or more redo log files. A redo log is made up of
redo entries (also called redo records).
The primary function of the redo log is to record all changes made to data. If
a failure prevents modified data from being permanently written to the
datafiles, then the changes can be obtained from the redo log, so work is
never lost.
To protect against a failure involving the redo log itself, Oracle allows a
multiplexed redo log so that two or more copies of the redo log can be
maintained on different disks.
The information in a redo log file is used only to recover the database from a
system or media failure that prevents database data from being written to the
datafiles.
For example, if an unexpected power outage terminates database operation,
then data in memory cannot be written to the datafiles, and the data is lost.
However, lost data can be recovered when the database is opened, after
power is restored.
By applying the information in the most recent redo log files to the database
datafiles, Oracle restores the database to the time at which the power failure
occurred.
The process of applying the redo log during a recovery operation is called
rolling forward.
Parameter Files
Parameter files contain a list of configuration parameters for that instance
and database.
Backup Files
To restore a file is to replace it with a backup file. Typically, you restore a file
when a media failure or user error has damaged or deleted the original file.
Tablespaces
A database is divided into logical storage units called tablespaces,
which is the largest logical structure.
Tablespaces commonly group together all application objects to
simplify some administrative operations.
One or more datafiles are explicitly created for each tablespace to
physically store the data of all logical structures in a tablespace.
Extents
The next level of logical database space is an extent. An extent is a
specific number of contiguous data blocks, obtained in a single
allocation, used to store a specific type of information.
Segments
Above extents, the level of logical database storage is a segment. A
segment is a set of extents allocated for a certain logical structure.
The Database Buffer Cache is the portion of the SGA that holds copies of data
blocks read from datafiles.
The write list holds dirty buffers, which contain data that has been modified but
has not yet been written to disk.
The LRU list holds free buffers, pinned buffers, and dirty buffers that have not
yet been moved to the write list.
Free buffers do not contain any useful data and are available for use.
Pinned buffers are currently being accessed.
When an Oracle process accesses a buffer, the process moves the buffer to
the most recently used (MRU) end of the LRU list. As more buffers are
continually moved to the MRU end of the LRU list, dirty buffers age toward the
LRU end of the LRU list.
If the process cannot find the data in the cache (a cache miss), it
must copy the data block from a datafile on disk into a buffer in the
cache before accessing the data.
SGA
Shared Pool Redo Log Database Buffer Cache
LGWR
DBWR
User proc.
Data Files
Database Systems Slide 16
Redo Log Buffer
The Redo Log Buffer is a circular buffer in the SGA that holds
information about changes made to the database.
The background process LGWR writes the redo log buffer to the
active redo log file (or group of files) on disk.
The shared pool portion of the SGA contains following buffers for
parallel execution messages, and control structures:
the library cache,
the dictionary cache,
Library Cache
The library cache includes:
the shared SQL areas,
private SQL areas,
PL/SQL procedures and packages,
control structures such as locks and library cache handles.
Shared SQL areas are accessible to all users, so the library cache is
contained in the shared pool within the SGA.
Oracle represents each SQL statement it runs with a shared SQL area and a
private SQL area. Oracle recognizes when two users are executing the same
SQL statement and reuses the shared SQL area for those users. However,
each user must have a separate copy of the statements private SQL area.
A shared SQL area contains the parse tree and execution plan for a given
SQL statement. Oracle saves memory by using one shared SQL area for
SQL statements run multiple times, which often happens when many users
run the same application.
Oracle allocates memory from the shared pool when a new SQL statement is
parsed, to store in the shared SQL area. The size of this memory depends
on the complexity of the statement.
If the entire shared pool has already been allocated, Oracle can deallocate
items from the pool using a modified LRU (least recently used) algorithm
until there is enough free space for the new statements shared SQL area.
If Oracle deallocates a shared SQL area, the associated SQL statement
must be reparsed and reassigned to another shared SQL area at its next
execution.
A private SQL area contains data such as bind information and runtime
memory structures.
Each session that issues a SQL statement has a private SQL area.
Each user that submits the same SQL statement has his or her own private
SQL area that uses a single shared SQL area. Thus, many private SQL
areas can be associated with the same shared SQL area.
The private SQL area of a cursor is itself divided into two areas whose
lifetimes are different:
The persistent area, which contains, for example, bind information. It is
freed only when the cursor is closed.
The run-time area, which is freed when the execution is terminated.
Oracle creates the runtime area as the first step of an execute request. For
INSERT, UPDATE, and DELETE statements, Oracle frees the runtime area
after the statement has been run. For queries, Oracle frees the runtime area
only after all rows are fetched or the query is cancelled.
If a session is connected through a dedicated server, private SQL areas are
located in the server processs PGA. However, if a session is connected
through a shared server, part of the private SQL area is kept in the SGA.
If the size of the Streams Pool is greater than zero, then any SGA
memory used by Streams is allocated from the Streams Pool.
If the size of the Streams Pool is zero, then the memory used by
Streams is allocated from the Shared Pool and may use up to 10% of
the Shared Pool.