I'd like to store ip2location database in a postgres database.
Guide on ip2location website suggests to store IP addresses that specify the range (ip_from and ip_to) in columns of type DECIMAL(39, 0).
I would have expected this to be of type INET.
Is there any advantage (e.g. in terms of speed, size, ...) to use DECIMAL(39, 0) instead of INET? Other than the ip2location database format contains IPs converted to integers already and one would have to convert that back to IP addresses obviously.
The advantage of using the
inetdata type areit takes up only 4 bytes to store an IPv4 address
you can make use of all the useful built-in functions and operators for IP addresses and CIDRs
There is no advantage in using
NUMERIC(39), except that it seems to be required by the software you want to use.