Disk Space Management And Pages

From persistence and price concerns, all the data of a database needs to be stored on disk. The disk space manager is the DBMS component that works closely to the operating system. The disk space manager hides details of the underlying hardware and allows DBMS components to think of the data as a collection of pages. The disk space manager creates the concept of a page as a unit of data, and provides instructions to allocate
or de-allocate a page and read/write a page. Page size may be chosen depending on the size of a disk block. It is recommended to pick a size less than block size, so that a page can be retrieved in one disk I/O.

If some data is accessed in squential order, we should allocate a sequence of pages as a contiguous sequence of blocks. This capability is essential
for databases for performance reasons. ideally such provisions should be propagated to higher level software modules to exploit the sequential access access mechanism in magnetic disks.

blocks-n-pages

Managing the block storage:

When data values are inserted, modified and deleted over a time period, the record size increases or decreases. So the row distribution in pages may change. The disk space manager keeps track of which pages are on which disk blocks and which blocks have been used. Over time new disk blocks may be used for the same number of records or some blocks may lose all the records. A list of free blocks can be maintained to make the allocation independent of the block layout on disk. When new blocks are required, they can be deleted from free blocks list. When blocks are de-allocated, they can be added to the free blocks list.

Another fast and efficient mechanism is to maintain a bitmap, where one bit represents a block. Setting and unsetting of the bit will indicate free or used block. When the disk space is very large, the bit map method may have a cost of loading the bit map in memory.