How fast is perl hash select?

168 views Asked by At

I use Perl hash to store ip -> hostname pairs. I have millions of it.

I cache gethostbyip syscall in the hash %HOSTNAME{$ip}.

Memory is not the issue. Time is.

How fast perl hash search works in this condition?

Will it work faster if I will use MysqlDB or BerkleyDB instead?

1

There are 1 answers

2
Dave Sherohman On

Assuming that you have sufficient RAM to hold all of the data, in-memory lookups will just about always be faster than retrieving data from an external source (disk, database, etc.) because RAM is fast and I/O operations are slow.

If you can't hold it all in RAM, then it becomes less predictable and you may need to benchmark to determine what's faster for your particular combination of program and hardware.