Home > Articles > Data > Oracle

📄 Contents

  1. Introduction to SGA
  2. Database Block Size
Like this article? We recommend

Like this article? We recommend

Database Block Size

Choice of an appropriate block size for a database is often one of the most important decisions that can affect the performance of the system. Choosing the proper block size requires a very good understanding of the application environment. Most often the "one size fits all" philosophy is not suitable for Oracle databases, and DBAs have a very difficult time making the right choice. Prior to Oracle9i, the block size for an Oracle database was fixed during database creation time and could not be changed throughout the life of the database. To make matters worse, changing the database block size is not a trivial process (as described later in this article). In addition, prior to Oracle 7.3, the maximum number of extents for an object was limited by the block size; for example, with a block size of 2048 the maximum number of extents was 121. However, from Oracle 7.3 onward this restriction was lifted, and objects are now allowed to have unlimited number of extents. Oracle9i addresses this issue and allows up to four additional nonstandard block sizes to exist in a given database.

Changing Database Block Size

As mentioned earlier, the database block size is fixed during database creation time and cannot be changed without database re-creation. The parameter DB_BLOCK_SIZE from the initialization file is used to determine the block size for a database being created. (Check your operating system documentation to determine the valid settings for DB_BLOCK_SIZE.)

Before attempting to change the block size of an existing database, you should ensure that you have a full and up-to-date backup of the database so that you can recover it if necessary. You should also determine how you will transfer the data into the new database. The following options are available:

  • Take a full database export and then import the data into the new database. This is probably the simplest option.

  • Using SQL*PLUS or some other mechanism, dump the data into flat files and then use SQL*Loader to load the data from the flat files into the database.

  • Use database links from the existing database into the new database and transfer data using these links. This option requires that you create the new database and also keep the old database until all the data has been transferred.

  • Load and unload the data using Pro*C, Pro*COBOL, or another such application.

It is important to realize that you cannot take a cold backup of the database and introduce the database files into the new database. Data has to be extracted at the logical level and then loaded into the database.

The following general steps can be used to change the database block size:

  1. Take a full cold backup of the database.

  2. Using the selected data transfer method (see options discussed above), extract the data from the database.

  3. Shut down and delete the existing database (if the database is no longer needed).

  4. Change the DB_BLOCK_SIZE parameter in the initialization file to the desired value. This initialization file will be a new file if the existing database is to be kept.

  5. Create the new database.

  6. Using the selected data transfer method, transfer the data into the new database.

Choosing the Proper Database Block Size

The proper choice of database block size depends to a large extent on the type of data involved and the application. The following guidelines can help in this process:

  • Operating system block size. Good performance can be achieved by ensuring that the Oracle block size is equal to or a multiple of the operating system block size. If this is not the case, the OS may end up performing extra reads and writes during the processing of Oracle blocks, resulting in wasted CPU cycles.

  • Size of buffer cache used. Larger database block size means that you are using up more memory for the same number of DB_BLOCK_BUFFERS. This also means that more rows are cached. If your rows are small and you use a large block size, a block fetch will result in a lot of rows being fetched (and you may not be interested in all of them). The end result is that the OS is doing more work to fetch things that you don't need. On the other hand, if the row length is large, a large block size may prevent chaining.

  • Balancing of index branches. Large Oracle block sizes can result in better index balancing, as there are more rows in each branch.

Block Size in Oracle9i

The main reason for the difficulty in supporting multiple block sizes prior to Oracle9i was that the SGA was not architected to support this. Keep in mind that when data is read from the physical data files, they are actually cached in the database buffer cache (unless it is a direct read operation). The size of the database buffer cache is determined by the DB_BLOCK_SIZE and DB_BLOCK_BUFFERS parameters as follows:

Database buffer cache size = DB_BLOCK_SIZE x DB_BLOCK_BUFFERS

From Oracle9i onward, the DB_BLOCK_SIZE initialization parameter specifies the standard block size for the database. This block size is used in the SYSTEM tablespace and by default in other tablespaces. Oracle9i supports up to four additional nonstandard block sizes. If a DB_BLOCK_SIZE is not specified, the default data block size is specific to the operating system. The following things should be considered while choosing the DB_BLOCK_SIZE parameter:

  • Choose the most commonly used block size as the database block size.

  • Choose the database block size to be a multiple of the operating system's block size.

  • Understand the nature of transactions run against the database. Larger block sizes can help in decision support systems (DSS) and provide greater efficiency in disk and memory I/O.

In Oracle9i, you can use the create tablespace command and specify the BLOCKSIZE clause to create tablespaces of nonstandard block sizes. These nonstandard block sizes can have any power of two values between 2K and 32K. Note, however, that some platform-specific restrictions may prevent the use of certain sizes on some platforms. This flexibility of having tablespaces of different block sizes in the same database is particularly useful if you plan to transport tablespaces from one application environment to another.

Use of multiple block sizes requires that you configure sub-caches within the buffer cache area of the SGA for all of the nonstandard block sizes that you plan to use. In other words, in order to use multiple block sizes in the database, the DB_CACHE_SIZE and at least one DB_nK_CACHE_SIZE parameter must be set. The DB_CACHE_SIZE parameter specifies the size of the cache for standard block size buffer (the standard block size itself is specified by DB_BLOCK_SIZE). The size and numbers of nonstandard block size buffers are specified by the dynamic parameters. In the following table, the parameter in the first column specifies the size of the buffer cache for a block size as shown in the second column.

Parameter

Block Size

DB_2K_CACHE_SIZE

2KB

DB_4K_CACHE_SIZE

4KB

DB_8K_CACHE_SIZE

8KB

DB_16K_CACHE_SIZE

16KB

DB_32K_CACHE_SIZE

32KB


The MAX_SGA_SIZE initialization parameter specifies the maximum size of the SGA for the lifetime of the instance. Oracle9i allows you to dynamically change the initialization parameters affecting the size of the buffer caches, shared pool, and large pool—but only to the extent that the sum of these sizes combined with the size of the other SGA components (fixed SGA, variable SGA, and redo log buffers) doesn't exceed the size specified by MAX_SGA_SIZE.

Tablespaces that make use of nonstandard block sizes can be determined by using the following script:

set echo off feedback off pagesize 50 term off linesize 80
spool tblspce_with_non_std_blksize.txt
select Tablespace_Name,
    Block_Size
from DBA_TABLESPACES
where Block_Size != (select Value
           from v$parameter
           where name = 'db_block_size');
spool off
set newpage 1 verify on feedback 6 pagesize 24
set linesize 80 heading on

Sample output of running the above script is shown below:

TABLESPACE_NAME                BLOCK_SIZE
------------------------------ ----------
DRSYS                          8192
TABLESPC4K                     4096
TABLESPC8K                     8192
INDX                           4096
PROJECTS                       8192
TOOLS                          16384
USERS                          8192

Note that you can query the parameter DB_BLOCK_SIZE to determine the standard block size in use for a given database. The above output indicates that the nonstandard block sizes in use for the database are as follows:

  • 4KB (tablespaces TABLESPC4K and INDX)

  • 8KB (tablespaces DRSYS, TABLESPC8K, PROJECTS, and USERS)

  • 16KB (tablespace TOOLS)

In Oracle9i, the size of the SGA can be static as in the prior releases or it can be dynamically configured. This means that the following primary parameters used to size the SGA can be changed while the instance is running:

  • Buffer cache. The size in bytes of the cache of standard blocks, specified by DB_CACHE_SIZE, can be changed dynamically. However, the cache size of the nonstandard block sized buffers is not dynamic in Oracle9.1.x.

  • Shared pool. The size in bytes of the area used by shared SQL and PL/SQL statements, specified by SHARED_POOL_SIZE, can be changed dynamically.

  • Large pool. The size in bytes of the large pool used for session memory in shared server systems, parallel execution for message buffers, any backup and restore processes by disk I/O buffers, as specified by LARGE_POOL_SIZE, can be changed dynamically. LARGE_POOL_SIZE cannot be changed dynamically in Oracle9.0.1.

Part 2 in this series, "Sizing the Database Cache," discusses how to size the database cache in an Oracle9i database. The article also discusses several general guidelines, as well as some specific tips for e-business environments.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020