Are you entirely sure that all the entries in your SQL table are unique? If not, putting those not unique entries into a hash will only keep one entry per "unique" value and hence a reduction of the total number of keys.
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
My blog: Imperial Deltronics