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 7062281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:34:30+00:00 2026-05-28T04:34:30+00:00

I have a rather large table with 150,000 + records. It has a lot

  • 0

I have a rather large table with 150,000 + records. It has a lot of fields like country_id, region_id, city_id, latitude, longitude, postal_code, to name just a few.

I need to select from this table based on the latitude and longitude, nothing else. My query looks like this:

SELECT * FROM `mytable` 
  WHERE `latitude` = '$latitude' 
  AND `longitude` = '$longitude';

Now although my sole criteria for selecting from this table is latitude/longitude I was wondering if adding more specificity would quicken the query like:

SELECT * FROM `mytable` 
  WHERE `city_id` = '320' 
  AND `latitude` = '$latitude' 
  AND `longitude` = '$longitude';

It seems counter intuitive to me that adding more conditions to the query would speed it up but at the same time I am narrowing down the number of possible results by a large margin by first making sure all the records selected are from a particular city id which I know resides in the latitude and longitude range I am going to be specifying by next.

There may be around 150k total records but only about 10k from that particular city.

So is this sensible at all or am I just making the query more time consuming?

  • 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-28T04:34:31+00:00Added an answer on May 28, 2026 at 4:34 am

    In general, adding conditions to a WHERE clause in your query will not have much impact on execution time. However, if you add indexes to the fields mentioned in your WHERE clause, you could considerably improve performance.

    So in your example, if there is not an index on city_id and you were to add that condition to your WHERE clause and create an index on that field, you would likely see a considerable performance improvement.

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

Sidebar

Related Questions

I have a rather large mysql table that has the following structure: fieldid |
If I have a large table with a column which has a rather limited
I have a rather large (many gigabytes) table of data in SQL Server that
I have a rather large file (150 million lines of 10 chars). I need
I have a rather large text file that has a bunch of missing newlines,
So I am using jQuery and I have a rather large table for what
I have a website that uses JQuery to construct a rather large table. When
I have a rather large table that takes about 10-20 seconds to fetch depending
I have a rather large table data I need to print, but when I
I have rather large input XML files that must be converted to a given

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.