Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1110779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:26:45+00:00 2026-05-17T02:26:45+00:00

I need to select a row from table that has more than 5 millions

  • 0

I need to select a row from table that has more than 5 millions of rows. It is table of all IP ranges. Every row has columns upperbound and lowerbound. All are bigintegers, and the number is integer representation of IP address.

The select is:

select * 
  from iptocity 
 where lowerbound < 3529167967 
   and upperbound >= 3529167967 
 limit 1;

My problem is

…that the select takes too long time. Without index on an InnoDB table, it takes 20 seconds. If it is on MyISAM then it takes 6 seconds. I need it to be less than 0.1 sec. And I need to be able to handle hundreds of such selects per second.

I tried to create index on InnoDB, on both columns upperbound and lowerbound. But it didn’t help, it took even more time, like 40 seconds to select ip. What is wrong? Why did index not help? Does index work only on = operator, and >,< operators can’t use indexes? What should I do to make it faster to have less than 0.1 sec selection time?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:26:45+00:00Added an answer on May 17, 2026 at 2:26 am

    Did you create one index on both columns, or two indexes one column each? If only one index, then this could be your problem, make one index for each. Indexes should still work for < and >

    Aside from changing indexes around, run:

    EXPLAIN
    select *
    from iptocity
    where lowerbound<3529167967
      and upperbound>=3529167967
    limit 1;
    

    Same query as you had, just added EXPLAIN and some linebreaks for readability.

    The EXPLAIN keyword will make MySQL explain to you how it’s running the query, and it will tell you whether indexes are being used or not. For any slow running query, always use explain to try figuring out what’s going on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to select all rows from one table which match one or more
I need a select from table which does not have column that tells when
I have need to select a number of 'master' rows from a table, also
I have a process that needs to select rows from a Table (queued items)
So I have a table that's basically a tree. Each row has a parent
I need to select a bunch of data into a temp table to then
I need the Select Data Source dialog added to my application so that the
I need to select a datetime column in a table. However, I want the
I need to execute a select and then update some of the rows in
I need to write a select query that joins the tables based on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.