|
People, even experienced DBAs, dealing with Oracle often confuse the idea of what a database is with what an instance is. Oracle ServerThe files, processes, and memory structures, whether used when processing SQL statements or not, make up the Oracle Server. The Oracle Server consists of the Oracle instance and the Oracle database. DatabaseAn Oracle database consists of the physical datafiles and the other physical supporting files that assist in the controlling of the access and operation. The collection of data is treated as a single unit. To interact with these files, and the information in these files, you need the assistance of the operating system (for resources such as memory and I/O subsystem) and a set of specific Oracle-created processes. InstanceAn Oracle instance, the set of Oracle-created processes and specific memory allocation that allow users to access the information stored in the database's datafiles, performs the work necessary for the efficient maintenance of the system and the efficient access and manipulation of the information resident in the database. Although you often hear people talking about a database being "up" or "down" (or…shudder…"crashed" for that matter), it really means that the instance is up, down, or crashed. Physical files can be corrupt or deleted, but only the processes of the instance can be up or down. Data BlocksThe smallest logical component of an Oracle database is the Data Block, often also referred to as Oracle blocks, and the smallest unit of space allocation possible. Data Blocks are defined in terms numbers of bytes, for example 2KB, 4KB, or 8KB. The database's standard block size is set in the DB_BLOCK_SIZE initialization parameter and is allocated in powers of 2KB, typically up to 32KB. Although you add space to a database in bytes, kilobytes, or even megabytes or gigabytes, because a data block is the smallest unit of storage that Oracle can manage or retrieve in a read operation, it is important that you work with your system administrator to determine the disk block size (covered in the following section) of the operating system and make the data block size a multiple of the operating system's disk block size. This allows you to take best advantage of the underlying operating system's capability to read and write larger chunks of data to disk in a single I/O operation. It is important to note that in prior releases, Oracle allowed only one block size to be in a database. There was no facility for allowing multiple block sizes in the same database. Oracle has provided much flexibility and ease of management in providing this capability. Data blocks are made up of the following pieces (see Figure 1.1):
Figure 1.1. Components of Oracle data blocks.Block Size ChoicesCarefully consider the purpose of your database at its creation time. Its purpose will impact the standard block size that you will want, and the standard block size is difficult to change after the database's creation and requires a total rebuild of the database to make this change. Typically, smaller block sizes are used for systems that have smaller rows, and you have inserts, updates, and deletes occurring frequently, as in an Online Transaction Processing (OLTP) system. Larger block sizes are usually used for systems where there are many large queries but less frequent updates, as in a data warehouse or an Operational Data Store (ODS) or a Decision Support System (DSS). Although Oracle's default block size, if the DB_BLOCK_SIZE is left unset, is 2KB, even a busy OLTP environment would benefit from a block size of around 8KB.
If you find that you have need for multiple block sizes in a database, with release 9i, Oracle provides that capability as well. You can now allocate four nonstandard block sizes in addition to the database's standard block size. It is important to remember that you have to also configure the corresponding DB_nK_CACHE_SIZE to go along with the nonstandard block sizes that you intend to use. Cache sizes can be set to any size but will be rounded to the nearest granule. A granule is either 4MB for a System Global Area (SGA) with a total size less than 128MB, or 16MB for a larger SGA. We cover the SGA later in this chapter. The standard buffer cache is set using the DB_CACHE_SIZE parameter and, if left unset, defaults to 48MB. Individual buffer caches (covered in more detail later in the chapter) need to be defined for each nonstandard block size before that block size can be used to define a tablespace. These additional buffer caches are set up with the following initialization parameter. A database with an 8KB standard block size might have the following nonstandard buffer cache sizes:
Again, each cache to be used must have at least one granule assigned to it, and the instance has to be restarted before the changes to these parameters can take effect. Although Oracle 9i has been widely publicized as a dynamic database with parameters that mean that the instance no longer has to be restarted for changes to take place, this is not necessarily true in all cases. A significant number of initialization parameters still are static and do require the data-base to restart for their changes to take place. DB_nK_CACHE_SIZE is one such parameter.
Now you can create a tablespace using the nonstandard block size: CREATE TABLESPACE my_smallblock_tblsp BLOCKSIZE 2048;
Disk BlocksThe disks on which the Oracle blocks reside are also divided into areas of contiguous storage of bytes, called disk blocks, or OS blocks. Typically, these blocks are referred to by the number of bytes involved rather than the number of KB. Different operating systems have different standard block sizes. Some are 1024 (1KB), some 512 (.5KB), and others 4096 (4KB) or even 32768 (32KB) or more. ExtentsSeveral contiguous data blocks make up an extent. Oracle allocates an extent only if it can find sufficient contiguous data blocks to allow for the extent to be created in a single allocation. Tablespace type plays a part in determining how Oracle allocates extents. Dictionary managed tablespaces allow you to specify the beginning allocation of space and the future increments as necessary.
Locally managed tablespaces use a simpler method, allocating uniform extent sized, chosen automatically by the database. Not only do you not have to worry about setting the initial and next extent size, if you do set the size in an allocation, Oracle ignores what you set. All database objects get allocated a certain amount of space when they are created. This initial space allocation is called the initial extent. After an extent is allocated to a table or an index, the extent remains allocated to that particular object until either that object is dropped from the database, at which time, the extents revert back to the pool free space waiting to be allocated in the database, or the object is truncated with the DROP STORAGE clause or the REUSE STORAGE clause associated with the truncate command. SegmentsSegments are made up of two or more data blocks that are themselves allocated to an extent that is allocated to a specific logical structure. A single segment can span multiple datafiles belonging to the tablespace to which the segment also belongs. Table 1.1 provides a summary of the common segment types along with their descriptions.
Each database object created has its own segmentevery table, every index, everythingand every segment is named after the object it was created for. Any space that gets allocated for these segments remains allocated, even if the object is truncated (unless you specify either TRUNCATE with REUSE STORAGE or trUNCATE with DROP STORAGE), until that object is deleted from the database. |
|