Heap File Organization in DBMS

Heap File Organization

This is the simplest form of file organization. Here records are inserted at the end of the file as and when they are inserted. There is no sorting or ordering of the records.  Once the data block is full, the next record is stored in the new block. This new block need not be the very next block. This method can select any block in the memory to store the new records. It is similar to pile file in the sequential method, but here data blocks are not selected sequentially. They can be any data blocks in the memory. It is the responsibility of the DBMS to store the records and manage them.

If a new record is inserted, then in the above case it will be inserted into data block 1.

When a record has to be retrieved from the database, in this method, we need to traverse from the beginning of the file till we get the requested record. Hence fetching the records in very huge tables, it is time consuming. This is because there is no sorting or ordering of the records. We need to check all the data.

Similarly if we want to delete or update a record, first we need to search for the record. Again, searching a record is similar to retrieving it- start from the beginning of the file till the record is fetched. If it is a small file, it can be fetched quickly. But larger the file, greater amount of time needs to be spent in fetching.

In addition, while deleting a record, the record will be deleted from the data block. But it will not be freed and it cannot be re-used.  Hence as the number of record increases, the memory size also increases and hence the efficiency. For the database to perform better, DBA has to free this unused memory periodically.

Advantages of Heap File Organization

  • Very good method of file organization for bulk insertion. i.e.; when there is a huge number of data needs to load into the database at a time, then this method of file organization is best suited. They are simply inserted one after the other in the memory blocks.
  • It is suited for very small files as the fetching of records is faster in them. As the file size grows, linear search for the record becomes time consuming.

Disadvantages of Heap File Organization

  • This method is inefficient for larger databases as it takes time to search/modify the record.
  • Proper memory management is required to boost the performance. Otherwise there would be lots of unused memory blocks lying and memory size will simply be growing.
Translate »