Questions about efficiently querying IP address segments, thank you

Source: Internet
Author: User
MySQL database:

User table, about 2000 data, has an IP field (converted to an integer);
IP Address Table (IP), 440,000 data, an IP Start field and IP End field (converted to an integer), and IP Physical Address field;

Now you need to use SQL script to find the "user table" each record IP corresponding to the physical address, with the following SQL script query speed is too slow, waiting for a long time no results

Select User.*, ip.addressfrom user left join Ipon user.ip between Ip.ipstart and Ip.ipend



Ask for more efficient methods of inquiry, thank you


Reply to discussion (solution)

Press EXPLAIN information to adjust

Press EXPLAIN information to adjust



What do you mean, I don't understand, thank you!

Execute EXPLAIN your query instructions
MySQL will tell you where it might be optimized


Press EXPLAIN information to adjust



What do you mean, I don't understand, thank you!


Moderators mean you EXPLAIN/DESC parsing SQL statements

It's too complicated, it's complicated,

1+1=2 is simple, but only 1+1=2 is no food.
1+1=1 is complicated, and people who study 1+1=1 always have food.

The moderator's words are too abstruse ...

So insightful.

Version of the bishop taught me, how to optimize, I learn from you,

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.