Saturday, February 19, 2011

What is Oracle Data Block?

What is Block?
Block  is sequence of bits or bytes with pre defined size called block size and entire block is read at a time from disk drive.

Ok that is what block is all about. Let move further and review block from 3 different point of views - Disk Drive's physical block , Operating System's filesystem block &.Oracle data block.

Disk Drive's physical block : The term block refers to a sector or group of sectors. Sector is smallest storage unit on disk drive which generally hold 512 bytes of data and read entirly by head at a time.

Operating System's filesystem block :  Filesystem are responsible for accessing and writing blocks of data  and size of  block is multiple of physical blocks. On windows term allocation unit or cluster are also used for block
On Windows NTFS filesystem block size and physical block can be determined by command fsutil fsinfo ntfsinfo drive:
In the figure below NTFS block size is 4096 as metioned in front of Bytes Per Cluster: & 512 is Phyiscal Block size as mention in front of bytes per sector :


On Linux
Physical block size can be determined using command fdisk -l
In figure below 512 is Pyscical Block Size which is Bytes per Sector.

Tracks are cocentric circles on platter of  disk drive and
Cylinder is set of tracks placed above one another having same track number in a platter of disk drive.
Total Number of cylinders are equal to number of tracks on single side of platter
Total Number of tracks in a cylinder is equal to number of heads since one head is for one side of platter.


Let us examine the summary portion of fdisk in detail
255 heads so total number of tracks in a cylinder are 255,
63 sectors/track
60801 cylinders units means there are total number 60801 cylinders on disk drive
cylinders of 16065*512=8225280 means total number of sectors in a cylinder is 16065 and each sector is of size 512 bytes so size of cylender is 8225280.
Total Number of Sectors  in a Cylinder = Number of Heads * Sectors per Track.=255* 63=16065
Size of  a Cylinder = Total Number of Sectors in cylinder *  Bytes per sector =16065*512=8225280 bytes
Total size of a disk drive = Size of  a Cylinder * No of Cylinders=
8225280*60801=500105249280 bytes=468 GB

Sectors Per Side of a platter = Tracks per Side * Sectors per track=60801*63=3830463
Total Number of Sectors of disk drive= Sectors Per Side * Number of Heads=3830463*255=976768065
Total size of a disk drive = Total Number of Sectors of disk drive * bytes per sector=976768065*512
=500105249280 bytes=468 GB



On Linux filesystem block size can be determined by command /sbin/tune2fs -l /dev/hda1
In the figure below filesystem block size is 1024 as metioned in front of Block size.


Oracle Data Block :
In oracle Data Block is smallest unit of storage , which is multiple of operating system's filesystem block size.
Oracle Server process read entire data block is at a time. For instance a block constitute of 5 rows and only 1 row fullfill the where condition of select statement. Oracle server process will read entire data block  of 5 rows.
Size of oracle data block is defined at the time of database creation and is fixed for the lifetime of database untill database is created from the scrach.
Starting from Oracle 9i,Oracle support multiple block size from for tablespaces defined by initialisation parameter DB_nK_CACHE_SIZE n can be 2,4,8,16&32  and standard block size DB_BLOCK_SIZE

No comments:

Post a Comment