3 ms·
The "Store IP addresses as UNSIGNED INT" hint is a really bad idea. The application will break on IPv6 connected servers. The same applies to storing IP address
by kennu 17y ago
The "Store IP addresses as UNSIGNED INT" hint is a really bad idea. The application will break on IPv6 connected servers. The same applies to storing IP addresses in a very short field like VARCHAR(16). It's better to just use VARCHAR(254).
- encoderer 17y agoYour advice reads like a suggestion to suffer an actual problem today -- finding and sorting IPs without needing a UDF -- to prevent a possible future problem. I wrote a book in another comment above, so I agree that the list suffers from a lack of nuance. But I'd say calling this a "really bad idea" should just be replaced with saying "use some caution."
- kennu 17y agoMy advice was selfish. I run a personal server that is IPv6 connected, and sometimes web frameworks will break because the author tried to store e.g. REMOTE_ADDR in a VARCHAR(16) column. So I would like to promote the fact that IP address != 32 bits, and if you really want to optimize for IPv4 address lookup, your code needs to handle it as a separate, specialized case.