For efficient IP address segment query, thank you for the MYSQL database:
User table (user), which contains about 2000 pieces of data, has an IP field (which has been converted to an integer );
Ip address table (IP address), 0.44 million data records, an IP address start Field, an IP address end field (which has been converted to an integer), and an ip address physical address field;
Now we need to use an SQL script to find the physical address corresponding to the IP address of each record in user table. it is too slow to use the following SQL script to query data.
select user.*, ip.addressfrom user left join ipon user.ip between ip.ipstart and ip.ipend
How to query data more efficiently? thank you.
Reply to discussion (solution)
Adjust according to EXPLAIN information
Adjust according to EXPLAIN information
What do you mean? thank you!
Execute EXPLAIN your query command
Mysql will tell you where to optimize it.
Adjust according to EXPLAIN information
What do you mean? thank you!
The moderator means that you explain/desc SQL statement analysis
Too complicated, too complicated,
1 + 1 = 2 is very simple, but only 1 + 1 = 2 is not eaten
1 + 1 = 1 is very complicated. people who study 1 + 1 = 1 will always have meals.
The moderator's words are too esoteric...
Insightful
The moderator taught me how to optimize it. I will learn from you,