Hi Dave, I actually use couple of your modules in my project,
and I'm doing exactly what you did for UK mobile data, but for USA/CAN. It's also an SMS messaging server.
I couldn't find any reliable data for the carrier lookup for NANP numbers, and I ended buying the data from a commercial supplier.
Instead of DBM I'm using my own object persistance module, which works basically the same as DBM::Deep but faster.
I stored the data in one data file per area code.
Each data file was on average 20-40kB.
The lookups were doing fine and were fast,
the only problem was with IMPORTING huge CSV files with e.g. 20k phone numbers.
The whole import
procedure had to be finished within 20s, including saving them in the DB, checking if they unique, etc...,
and for 10k numbers, it means 10k lookups - reading
on average 300MB of data.
At this point it was taking on average 70s, so
I moved the data into something like this:
use constant _nanp_area =>
{
201 => {
4143 => 267,
206 => 357, .... },
604 => { ... },
....
};
# {
# { area_code1 => { prefix => carrier_id, ... },
# { area_code2 => { prefix => carrier_id, ... },
# }
So it's basically a hash of hashes of 3 or 4 digit prefixes and corresponding carriers.
I didn't do exact measurements, but it's fast enough, and works for us just fine. 10k phone numbers gets imported and stored in DB within 14s.
The lookup function first tries to find the carrier based on area code and 4 digit prefix, and if undef, then with 3 digit prefix.
At this point everything seems to work OK and fast, but I will keep my eye on it...