Professional Documents
Culture Documents
Main Presentation
Main Presentation
Storage Allocation
Introduction(1)
As we have seen already, database consists of tables, views,
index, procedures, functions etc.
The tables and views are logical form of viewing the data. But
the actual data are stored in the physical memory .
Database is a very huge storage mechanism and it will have
lots of data and hence it will be in physical storage devices –
like magnetic disk .
In the physical memory devices, these data cannot be stored
as it is. They are converted to binary format.
Each memory devices will have many data blocks, each of
which will be capable of storing certain amount of data.
The data and these blocks will be mapped to store the data in
the memory.
Overview of a Secondary Storage-
Magnetic Disk
Access Data in Magnetic Disk(2)
Traditional HDD has rotating drives
which stores data in tracks.
When the data needs to be read or
written, the actuator with an arm, needs
to go to the particular sector on the
track to read or write a data. This is
measured as seek time.
After that, the drive needs to rotate to
reach to a particular sector (rotational
latency).
When we are dealing with huge amount
of data, it might become a bottleneck
since disk has to continuously move to a
specific sector.
Average seek time vary from 4ms for
high end servers and 9ms for common
server.
How data Stored in Memory
• In linear data structure , for searching any elements in list, we have to visit all
elements.
• It is very slow and of O(n).
• So in memory, it is convenient that data is stored in non-linear data structures in
which data is organized in a hierarchical manner.
• A tree structure represents hierarchical relationship among its elements.
• It is very useful for information retrieval and searching in it is very fast.
Motivation
• We assume that everything in a search tree is kept within the main
memory (including the balanced trees like AVL, red-black trees, splay
trees, etc.).
• What if the data items contained in a search tree do not fit into the main
memory?
• Just think about searching in the UIDAI database (for AADHAAR details).
• Let us assume there is only 8 Bytes of data (say the AADHAAR ID) per
citizen and we have to create a search tree.
• The population of India: 1,358,856,931.
• The search tree will require more than 20 GB memory (including
pointers)!!!
Search Tree on disk
• A majority of the tree operations (search, insert, delete, etc.)
will require O(log2 n) disk accesses where n is the number of
data items in the search tree.
• The main challenge is to reduce the number of disk accesses.
• An m-ary search tree allows m-way branching.
• As branching increases, the depth decreases.
• A complete binary tree has a height of ┌ log2 n ┐.
• But a complete m-ary tree has a height of ┌ logm n ┐.
Cycles to access different types of
storage
Storage Type Access Type Number of Cycles
L2 cache Random 2
L2 cache Random 30