[prev] 30 [next]

Insertion with Hashing

Insertion uses similar process to one queries.

// insert tuple t with key=val into rel R
// f = data file ... ovf = ovflow file
p = hash(val) % nPages(R)
P = getPage(f,p)
if (tup fits in page P) 
    { insert t into P; return }
for each overflow page Q of P {
    if (tup fits in page Q)
        { insert t into Q; return }
}
add new overflow page Q
link Q to previous overflow page
insert t into Q

Costinsert:    Best: 1r + 1w    Worst: 1+max(OvLen))r + 2w