there is an issue with the zipcodes.mysql data model - specifically a primary key of "zip" means that only 1 country at a time can be supported (or at least presumes that zipcodes are unique across all countries). while this might be idea, fact is, even in our two datasets (de and us) there is overlap.

the attached patch cleans up the data model a bit (changing keys to indices where appropriate, and using a more sane primary key).

CommentFileSizeAuthor
zipcodes-mysql.patch792 byteswalkah

Comments

ankur’s picture

Status: Needs review » Closed (works as designed)

The .mysql file may be a little confusing, but currently it creates the zipcodes file using (country, zip) as the primary key. We may actually want to change this to (country, zip, city) or (country, zip, province, city) since some countries have postal codes that cover more than one city... I say confusing because, in the zipcodes.mysql file, the actual "CREATE TABLE" statement creates the primary key of zip, but then right below it there are a couple of queries that (1) drop the primary key and (2) create a new primary key out of (country, zip).

As for changing the keys to indices, I ran some tests and using indices in place of keys seems to slow down some of the query times by a factor of around 2%, at least on my development machine.

-Ankur