sql - create a table for each country that is needed - mysql -


i have database structure this:

  • t_person(idp, idcity, name, addr, tels, zip, desc, premium)
  • t_city(idcity, idcountry, cityname)
  • t_country(idcountry, countryname)

i want general "live search" (google-like):

select p.name, p.addr, p.zip, p.desc, c.cityname, x.countryname,  match (p.name, p.addr, p.zip, p.desc)  against ('fred* tall* 94620*' in boolean mode) score t_person p inner join t_city c on c.idcity = p.idcity inner join t_country x on x.idcountry = c. idcountry  match (p.name, p.addr, p.zip, p.desc)  against ('fred* tall* 94620*' in boolean mode) , x.idcountry = 43 -- (i.e usa) order score desc, p.name asc, p.premium desc 

when there 1000 - 1500 rows, query runs in 0.011 secs when there 30000+ rows take 1.2+ seconds (i have tested data generator). question is, if create new table evey country(1 --- n) person, this:
t_person_uk, t_person_usa, t_person_spain, each 1500 rows, think way searches fast.
pd, have 0.25 second timeout before make ajax call search.
thanks, bye.

this not direct answer question @ all, bit long comment.

in general, these types of searches built full-text indexing search engines rather mysql. full-text search engine offer many more possibilities standard match mysql.

for example, able partial matches, return distance-sorted results, auto-suggest , auto-completes. mysql provide bare minimum: 1 matching function 2 or 3 modes.

a example of full-text indexing apache solr, built on top of lucene.

also, free , comprehensive database of geographic data available @ geonames.

hopefully not off-topic :)


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -