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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:29:25+00:00 2026-05-23T17:29:25+00:00

I have a database with ~100,000 entries – right now my query looks like

  • 0

I have a database with ~100,000 entries – right now my query looks like this:

SELECT id,zipcode,price FROM listings WHERE zipcode IN (96815 , 96815,
96835, 96828, 96830, 96826, 96836, 96844, 96816, 96847, 96814, 96822,
96823, 96843, 96805, 96806, 96810, 96848, 96808, 96809, 96842, 96839,
96802, 96812, 96804, 96803, 96840, 96807, 96813, 96841, 96801, 96850,
96811, 96898, 96837, 96827, 96824, 96846, 96821, 96817, 96859, 96838,
96819, 96820, 96858, 96849, 96825, 96795, 96863, 96818, 96853, 96861,
96734, 96744, 96701, 96860, 96709, 96782, 96706, 96797, 96862, 96789,
96707, 96730, 96854, 96759, 96786, 96857, 96717, 96792, 96762, 96712,
96791, 96731) AND (price BETWEEN 1000 AND 1200) ORDER BY id

This query worked fine when I had only 50,000 entries, but its getting really slow when I extend the radius of the zip codes (which results in even more zip codes in the in clause).

id int(8) AUTO_INCREMENT price mediumint(7)
zipcode mediumint(5)

All three fields are indexed. Does anyone have an idea how i could optimize it? Thanks guys

  • 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-23T17:29:26+00:00Added an answer on May 23, 2026 at 5:29 pm

    ZIP codes are generally geographically distributed — you might be able to speed things up by simplifying the ZIP code clause to something like:

    zipcode BETWEEN 96700 AND 96898
    

    This may end up inadvertently including some zip codes that you didn’t want, but it may end up being more efficient to filter them out later.

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

Sidebar

Related Questions

I have a database with almost 100,000 comments and I would like to detect
I have to read 100.000 rows from database, I use this code : List<elementClass>
I feel dumb right now. I got to update 100.000 rows on a database
I have more than 100 million unique strings (VARCHAR(100) UNIQUE in MySQL database). Now
I have Database with date field. I see the time like: 1900-01-01 13:38:00.000 How
i have database table like this +-------+--------------+----------+ | id | ip | date |
I have about 100,000 strings in database and I want to if there is
I have roughly 100,000 Objects that I want to insert into the database. I
we have a 500gb database that performs about 10,000 writes per minute. This database
I'm sorry if this seems like a random question, but I have a database

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.