Please refer "Database Management Systems by Raghu Ramakrishnan" - Chapter 8

Table with more clarity :

Scan column → Cost of reading entire file
Equality column → Cost of = selection
Range column → Cost of range selection
Insert column → Cost to insert one record
Delete column → Cost to locate + remove record
B = Number of data pages (blocks) required to store the file when records are packed with no wasted space
R = Number of records per data page (records per block)
D = Average disk I/O time to read or write one data page
C = Average CPU time to process one record (e.g., compare a field with a constant)
H = Time required to apply the hash function to one record
F = Fan-out of a tree index (number of pointers per index node, typically ≥ 100)
Heap Files
BD = Cost of scanning all B data pages (full file scan cost)
0.5BD = Average cost of equality search in an unsorted heap file (half the file scanned on average)
Sorted Files
log2(B) = Height of binary search over sorted data pages
D log2(B) = Disk I/O cost of binary search on sorted file
Clustered Files
logF(B) = Height of a B+ tree index with fan-out F and B data pages
D logF(B) = Disk I/O cost to traverse a B+ tree index
#matches = Number of records that satisfy the selection condition
1. In clustered files, data pages are not fully packed.
2. Empirical studies show average page occupancy is about 67%.
3. Because of this, more physical pages are needed to store the same data.
4. Effective number of data pages ≈ 1.5 × B (where B is the ideal number of pages).
5. This 1.5B assumption is used in cost analysis.
6. Full file scan must read all data pages.
7. Therefore, scan cost = 1.5B × (D + RC).
8. This scan cost is similar to sorted files, but higher due to extra pages.
Search = Cost to locate the record position (depends on file organization or index)
Search + D = Search cost plus one data page access
Search + BD = Search cost plus shifting/reorganization of B data pages
Search + 2D = Search cost plus two data page accesses
1.5BD = Scan cost for clustered index (due to partial page overlap and ordering)
0.15B = Approximate number of index pages (15% of data pages, rule of thumb)
BD(R + 0.15) = Full scan cost including data pages and index pages
Heap File with Unclustered Tree Index
D(1 + logF(0.15B)) = One data page access plus index traversal cost
D(3 + logF(0.15B)) = Insert cost including index traversal and multiple page updates
2D = Cost of equality search using unclustered hash index (hash bucket + data page)
4D = Insert cost in unclustered hash index (bucket + overflow + data page updates)
1. We consider a heap file with an unclustered B+ tree index.
2. Each index data entry is assumed to be about 1/10th the size of a data record (a typical assumption).
3. Index pages are assumed to be about 67% full.
4. Because of entry size and page occupancy, the number of index leaf pages is about 0.15 × B, where B is the number of data pages.
5. Each index leaf page contains about 6.7 × R data entries (R = records per data page).
6. To scan using an unclustered index, we first scan all index leaf pages to get record pointers.
7. This index scan costs roughly 0.15B I/Os.
8. Now comes the expensive part: for each index entry, we must fetch the actual data record.
9. Since the index is unclustered, each record may lie on a different data page.
10. Therefore, fetching data records costs about 1 I/O per record.
11. Total cost of fetching records becomes approximately B × R I/Os, which is extremely high.
12. Hence, using an unclustered index for a full scan is inefficient.
13. If sorted output is needed, it is better to ignore the index and scan the data file directly.
14. Sorting the data file can be done using a two-pass external sort.
15. Two-pass sorting requires reading and writing the entire file twice.
16. So, the I/O cost of sorting a file with B pages is about 4B.
17. This cost (4B) is much smaller than the cost of scanning using an unclustered index.
18. Rule of thumb: never use an unclustered index for full scan or sorted retrieval.