Can I change the database block size?
Should I need to reboot instance after changing default block size?
When I should use large block size and when I should use small block size?
Here, I am going to share my knowledge about data block
size in oracle database. I hope it will be helpful to you .
v The first question is: “Is it
possible to increase or decrease the data block size?”
·
The DB_BLOCK_SZIE parameter specifies the
default block size in database. The block size varies from 2 KB (2048 bytes) to
32 KB (32768 bytes) . The default block size is 8 KB (8192 bytes).
· You can not change the database block size
(DB_BLOCK_SIZE parameter) once the database is created in Oracle 8i and all
earlier versions. Even you can’t create a new tablespace having different block
size than default block size of the database. The only way to change data block
size is to re-create entire database and change the DB_BLOCK_SIZE parameter in
initialization parameter file.
·
However, the Oracle 9i & later versions
allows you to use non-default block size. That is you can not change the
default block size of the database but
you can create a new tablespace having different block size than default block
size of the database by using “BLOCKSIZE”
clause while creating tablespace.
·
To create a tablespace having non default
block size
§ Tablespace must be locally managed
§ You must have to configure memory buffer cache in the memory area (SGA) for that block size. This can be configured by setting the DB_NK_CACHE_SIZE parameter in initialization parameter file
§ The DB_NK_CACHE_SIZE parameter specifies the size of default buffer pool.
§ If you try to create the tablespace without configuring buffer cache for non default block size then “ ORA – 29339” error will be thrown.
§ If the SGA is set and this parameter is not specified then default size of it 0. If the SGA is not set then the minimum size of this parameter must be 48 MB.
§ Tablespace must be locally managed
§ You must have to configure memory buffer cache in the memory area (SGA) for that block size. This can be configured by setting the DB_NK_CACHE_SIZE parameter in initialization parameter file
§ The DB_NK_CACHE_SIZE parameter specifies the size of default buffer pool.
§ If you try to create the tablespace without configuring buffer cache for non default block size then “ ORA – 29339” error will be thrown.
§ If the SGA is set and this parameter is not specified then default size of it 0. If the SGA is not set then the minimum size of this parameter must be 48 MB.
For
example, to create tablespace with non default block size (4k) in database
whose default block size is 8k
1. Alter system set db_4k_cache_size=48m;
2. Create tablespace test datafile “D:\oracle\orcl\data_files\test.ora” size 200m blocksize 4k extent management local;
1. Alter system set db_4k_cache_size=48m;
2. Create tablespace test datafile “D:\oracle\orcl\data_files\test.ora” size 200m blocksize 4k extent management local;
Thus, there is no need to bounce
your instance to change data block size.
v Now,
answer to other question “ How to decide when to use large block size and when
to use smaller one?”.
·
In data warehouse , larger data block size is
more preferred as oracle can retrieve more data in single i/o operation.
·
In production database, smaller data block size
is more efficient to minimize the contention for a specific data block due to
frequent DML operations.
·
The tablespace with larger block size should be
used to store indexes, tables having large number of rows and tables that
requires frequent full scans.
·
The tablespace with smaller block size should be
used to store tables having less records and tables that experiences frequent
DML operations.