PHP: the right way to store IP addresses in MySql and quickly search for IP addresses in millions of lines

I save the IPv4 addresses in the column type "int unsigned" with inet_aton. [Am I doing it right? And uses "unsigned" required?] This particular column is also indexed. Since there will be millions of rows and several rows containing the same IP address throughout the table, what would be the fastest way to find these rows?

.. or am I not mistaken about this?

+3
source share
3 answers

Am I doing it right? And uses "unsigned" necessary?

. unsigned IP- , int ( varchar) .

?

, , ( ..). , unsigned int .

+1

inet_aton - , ( 256 3 ). 32- , unsigned int.

int IP-. , , MySQL.

, , , Bad Thing (tm). , , , . nosql , , .

+2

, IP- MySQL.

INET_ATON, , UNSIGNED INT IP- 127 .

It is also a very quick way to search. MySQL handles entire columns perfectly, and by indexing that column and using INET_ATON in your search, you can get very fast queries.

+1
source

Source: https://habr.com/ru/post/1770578/


All Articles