Which sorting technique is used to sort databases, whose sizes are very big? Give one such algorithm. Why do sorting techniques like quicksort, insertion sort, etc. not applied on very big databases?
Ans: To sort a large database or file, the sort-merge (or k-way merge) algorithm is extensively used. This is one of the external sorting algorithms. External sorting algorithm considers to sorting algorithms that are appropriate for large file of records stored on disk that do not fit completely in main memory, like most database files. The sort-merge algorithm begins by sorting small subfiles --called runs - of the main file and then merges the sorted runs, making larger sorted subfiles which are merged in turn. Such as other database algorithms, it needs buffer space in main memory, in which the actual sorting and merging of the runs is performed. This algorithm contains two phases:
(1) the sorting phase, and
(2) the merging phase.
The sorting methods like quick sort, insertion sort, etc. are not applied on large databases as these are internal sorting algorithms, which need buffer space in main memory. The space complexities of these algorithms are O (n) and require a large buffer space in major memory to sort the large database. Hence, internal sorting algorithms are not applied on large databases.