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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:30:20+00:00 2026-05-25T11:30:20+00:00

i’m trying to use geonames database (downloaded and loaded on a local mysql) to

  • 0

i’m trying to use geonames database (downloaded and loaded on a local mysql) to get all associated informations from a location (lowest level is cityname) using Java and JDBC drivers.

I have a big performance issue: each query takes something like 4-5 seconds, and i have to split the query in three parts before getting all the results i need.

Basically, i have loaded the allCountries database, the admin1codes and the admin2codes. Since admin1 and admin2 unique ids are composed by information retrieved from the query on allcountries, i had to do something like this to query the database:

String query = "SELECT DISTINCT "
             + "loc_geoname.name AS name,"
             + "loc_geoname.asciiname AS asciiname,"
             + "loc_geoname.alternatenames AS alternames,"
             + "loc_geoname.latitude AS latitude,"
             + "loc_geoname.longitude AS longitude,"
             + "loc_geoname.country AS country_code,"
             + "loc_geoname.admin1 AS admin1, "
             + "loc_geoname.admin2 AS admin2, "
             + "loc_countryinfo.name AS country, "
             + "loc_countryinfo.currency AS value "
             + "FROM loc_geoname, loc_countryinfo "
             + "WHERE loc_countryinfo.iso_alpha2=loc_geoname.country "
             + "AND loc_geoname.asciiname IN (" + search + ") "
             + "AND loc_geoname.country='" + countrycode + "' "
             + "AND loc_geoname.fcode like 'PP%' limit 10;"

and this is the query i’m using to fetch all the info for a city (search and countrycode are strings prebuild, they’re not important)

now, to get the admin1 name and the admin2 name i have to launch two new queries:

String a1 = res.getString("admin1");
String query_area = "select name from loc_admin1Codes where code='" + countrycode + "." + a1 + "';";

String a2 = res.getString("admin2");
String query_district = "select name from loc_admin2Codes where code='" + countrycode + "." + a1 + "." + a2 + "';";

I’m sure its possible to combine the two queries into one (but not so sure) but i don’t know how to create the admin1 and admin2 codes without getting them values from the first query and combining strings into the second and the third.

Also, i’m sure i can improve my first query to speed it up a bit (maybe using joins instead of a cross combination with a where clause…)

Table structure is the same as defined here and i didn’t change anything from that.
Thanks all in advance for the hints!

  • 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-25T11:30:20+00:00Added an answer on May 25, 2026 at 11:30 am

    You shouldn’t request it every time.

    I did this by adding a column “admin1Nameé and “admin2Name” and I updated their value with a simple SQL query.

    This database is very large so you should think about calculated column.

    EDIT : if you still want to do it every time

    SELECT 
        locgeoname.*, 
        loc_countryinfo.name, loc_admin1Codes.name, loc_admin2Codes.name, 
    FROM 
        loc_geoname 
    INNER JOIN 
        loc_countryinfo ON loc_countryinfo.iso_alpha2 = loc_geoname.country
    INNER JOIN 
        loc_admin1Codes ON code = loc_countryinfo.iso_alpha2 + '.' + admin1  
    INNER JOIN 
        loc_admin2Codes ON code = loc_countryinfo.iso_alpha2 + '.' + admin1 + '.' + admin2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported

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.