4 ms·
I think a 32-bit hash of an IPv6 address will be fine for a long time, and remain much faster to search/sort than a 128-bit value. I also think that if you can
by geocar 11y ago
I think a 32-bit hash of an IPv6 address will be fine for a long time, and remain much faster to search/sort than a 128-bit value.
I also think that if you can't upgrade your database you're going to have other problems as well.
- IanCal 11y ago> I think a 32-bit hash of an IPv6 address will be fine for a long time Be careful with this, a 32 bit hash can see collisions with remarkably low numbers. A 50% chance of a collision is seen with ~75k entries: http://preshing.com/20110504/hash-collision-probabilities/ http://preshing.com/20110504/hash-collision-probabilities/ Depends on your application as to whether this is a problem or not.
- geocar 11y ago50% chance of one collision. Be careful with those maths!
- IanCal 11y agoYes, thanks for the clarification, it's what I meant with "a collision" but I realise that's ambiguous.
- geocar 11y agoNo worries, and you're absolutely right that it depends on your application whether this is a problem or not! Estimating population sizes? "Unrecognised IP addresses?" Probably fine. Interning the hash and using the real IP address in a database someplace? Probably not.
- nly 11y agoNo, it's a 50% probability of there being at least one collision (or, put another way, a 50% chance of there being no collisions).
- geocar 11y agoYou're absolutely right, but it won't let me edit it. Thanks!