I have a requirement to store 2 to 15 million Accounts (which are a String
of length 15) in a data structure for lookup purpose and checking uniqueness. Initially I
When we tried to store 50 million records in HashMap with proper initialization parameters, insertion started to slowdown, especially after 35 million records. Changing to TreeMap gave a constant insertion and retrieval performance.
Observation : TreeMap will give better performance than a HashMap for large input set. For a smaller set, of course HashMap will give better performance.