Select and Compare 500,000 RecordSet in MySQL

Discussion in 'MySQL' started by eopeter, Jul 22, 2008.

  1. #1
    I have a record of businesses with half a million records including zip code. I want to search for businesses within e.g 15 miles of 49931. I have a function that returns the distance between 2 zip codes but the issue is:

    going thru each recordset to determine the distance to 49931 takes forever and never returns. Is there a better way to this?

    databse is MySQL
     
    eopeter, Jul 22, 2008 IP
  2. spyrit

    spyrit Well-Known Member

    Messages:
    1,788
    Likes Received:
    94
    Best Answers:
    0
    Trophy Points:
    150
    #2
    hmmm, the only thing i can think of, is you make new tables for say 15miles table and put all the 2 zip codes that have that distance ...and so on. This will make your database a lot bigger though, but it would be only a matter of a select * after that to display them.

    or....try using LIMIT with your query and return only 20-30 records at a time..
     
    spyrit, Jul 22, 2008 IP